To detect two keystrokes closely followed, you can use EventListener
s for the onkeyup
/onkeydown
event. In combination with a variable that determines if the key was already pressed within the last 100 ms and a setTimeout
call that resets that variable after 100 ms, it should be fairly easy to accomplish.
this post was submitted on 10 Jun 2024
17 points (94.7% liked)
Firefox
17787 readers
22 users here now
A place to discuss the news and latest developments on the open-source browser Firefox
founded 4 years ago
MODERATORS
Probably you can inject your js and add an input event in the body of the page.
If you just need to intercept the keypresses in webpages then you can inject a content script and handle these. However there is no way with the new WebExtensions API to intercept browser chrome events.
Additionally there is no way to delay events. So if you want to suppress both shift presses you will struggle to do that. If you are ok to let the first one go through suppressing the second one is trivial.