Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if the ctrl button was pressed

Tags:

javascript

I want to prevent users from printing a page I thought I would set the screen to not include the toolbars, and prevent right clicks, and prevent Ctrl+ P, and the Print Screen button. Can this be done?

Is there any good code out there for this? I have searched quite a bit so far, but not much luck. I know this isn't foolproof, but it will prevent some users from copying or printing.

like image 549
Fred Avatar asked Aug 17 '26 04:08

Fred


1 Answers

You can't do this...you can't disable the user's ability to print, nor should you try.

Ctrl+P is the way a programmer prints, File > Print (depending on browser) is the way the typical user does...so this wouldn't even disable the most common method. In addition, any decent programmer can get around this anyway, so it effectively doesn't stop anyone.

Any data you get to a user, displayed or not, they can see, copy, print, etc...there's nothing you can do to prevent this, definitely not 100%. If this is one of your requirements...you should be asking if a website is the best way to deliver this data.

like image 101
Nick Craver Avatar answered Aug 18 '26 20:08

Nick Craver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!