Sciencemadness Discussion Board

Any _javascript gurus here? Website help.

Neal - 30-11-2022 at 18:41

I want to make the site popup a dialog like "Hello world!" when a user presses the PrintScreen button when on your site. Actually, just a popup that says "You have pressed the PrintScreen button."

I would prefer if it could be done without a batch file? Is that possible?

[Edited on 1-12-2022 by Neal]

Neal - 30-11-2022 at 18:42

JavaScript*

Weird, I tried to edit the title to capital J, and it makes it to _j. Forum bug?

Neal - 1-12-2022 at 05:02

Nevermind, got it to work.

SuperOxide - 16-12-2022 at 23:04

Neal, I'm a senior JS developer, so I'm rather curious how you got this to work because I've always thought that the browser can't detect things like if a user hits the PrtSc/Print Screen key.

P.S. I'm assuming when you say print screen, you mean the screen capture, instead of printing the page (which you can detect using things like the beforeprint event).

khlor - 25-12-2022 at 09:49

Quote: Originally posted by SuperOxide  
Neal, I'm a senior JS developer, so I'm rather curious how you got this to work because I've always thought that the browser can't detect things like if a user hits the PrtSc/Print Screen key.

P.S. I'm assuming when you say print screen, you mean the screen capture, instead of printing the page (which you can detect using things like the beforeprint event).


I think that instead of the event, he is tracking/listenning to keypresses, that is far easier to do, and is supported by virtually any moder JS capable browser.

Edit 1: text correction.

[Edited on 25-12-2022 by khlor]

SuperOxide - 26-12-2022 at 13:54

Quote: Originally posted by khlor  
Quote: Originally posted by SuperOxide  
Neal, I'm a senior JS developer, so I'm rather curious how you got this to work because I've always thought that the browser can't detect things like if a user hits the PrtSc/Print Screen key.

P.S. I'm assuming when you say print screen, you mean the screen capture, instead of printing the page (which you can detect using things like the beforeprint event).


I think that instead of the event, he is tracking/listenning to keypresses, that is far easier to do, and is supported by virtually any moder JS capable browser.

Edit 1: text correction.

[Edited on 25-12-2022 by khlor]

I thought about that, but I don't think that would work either.
https://stackoverflow.com/questions/54744316/keypress-event-...

Edit: I see there's an accepted solution there. But I can't test it very well. I'm on a mac (and it didn't work, but maybe windows it will)

[Edited on 26-12-2022 by SuperOxide]

khlor - 28-12-2022 at 09:34

Maybe you need to check system specific keybindings or maybe, system specific event listener limitations.

Raid - 18-1-2023 at 05:30

i know a bit of JS, mostly just using it for web-based cheats ;)