Global keyboard shortcut event listeners
Submitted by Andrew Loiacono
Certain web applications would benefit from system-wide event listeners. For example, Discords has an Electron app that enables users to set up keybindings that can be listened to for features such as push to talk or mute switching. The user would set up a button of their choice (ex. q, e, pause, etc.), and every time that button is pressed—whether the application is in the background or foreground—that action would be triggered.
Since Discord is more like a companion app to playing video games with your friends, most of the time the application is in the background. As far as I know there is no way to allow web applications to listen to keyboard events when they are not in focus.
This is a scary API, I know, but that is why I think there needs to be a lot of requirements before using this API. I’m assuming you don’t want websites listening to any keyboard event they so choose. You could possibly require the website to use HTTPS. You could also require the user to accept a permission on either system-wide event listeners for any key or individual keys. I also think that having a PWA installed could also very well be a requirement.