Capture System Keys

Helo

I need to capture system keys in Firefox. The need is to block them (Alt + Tab, Ctrl + Esc, WinKeys and all other special keys of sitemas as linux, windows, mac). I’ve tried various methods, but to no avail. I can capture simple keys like F11, Alt + F11 etc.

Could someone help me?

PS: also need to disable and restrict access to local files to upload and download boxes, able only to form buttons, but to Gmail for example is complicated, but will create another topic after resolving this.

Thank you

The keys you mention are controlled from outside Firefox.

Do you want to block the keys while just in firefox? If so you can do that with a keydown/keyup listener.

To block on the whole system you can do it with ctypes:

This is a mouse hook in winapi - https://gist.github.com/Noitidart/5c6ff7a7552277fa52e4

This is a keyboard hook in objective-c - https://gist.github.com/Noitidart/8645b47b0e46a0eb284e (for mac you might have to request accessibility from the accessibility api)

This addon here does some similar stuff - https://addons.mozilla.org/en-US/firefox/addon/media-keys/

1 Like

Thanks, but I need to just lock the ALT + TAB, CTRL + ESC, WINKEY etc …
The example I think that works for other things. Am sorry.

Your solution definitely is to use js-ctypes. You will likely have to hack hard too, because no platform makes it easy to disable these regular keys. I know on Windows, with the keyboard hook, I never did it, but while reading about this subject I saw I needed extra code to bypass the security on the system. It’s just not a user friendly feature. But I get it, you might need it for something like say “blocking students from switching windows or something during a computerized test”. On Mac I had to add extra code to request Accesibility API. I didn’t read about it on Linux but I worked a bit with their APIs (GTK/X11/XKCB) and it for sure will be easiest of the three. Linux doesn’t really bother you about being user friendly.

So it’s not impossible, it is very possible. Read here to learn about js-ctypes -

1 Like

Thanks for the tip. I will try to do a nice job for the kiosk.