Reputation: 95
Firefox on Windows 10 does not detect the Alt key on keydown
in conjunction with another key, but does detect the Shift key. Chrome and Edge detect both as expected.
In Firefox, the following snippet shows that event.shiftKey
is detected correctly, but event.altKey
is never detected. In Chrome and Edge, event.altKey
is detected correctly. (Pressing Alt or Shift triggers keydown
in Chrome and Edge, but not in Firefox, which is why I said "in conjunction with another key.")
<!doctype html>
<html>
<head></head>
<body></body>
<script>
document.addEventListener("keydown", function(event) {
console.log("Alt: " + event.altKey);
console.log("Shift: " + event.shiftKey);
}, false);
</script>
</html>
A question from 2019 reports the same problem in Firefox 69, but the solution was apparently that in Firefox, &&
breaks something when used to detect if multiple keys including Alt are being pressed.
A question from 2012 reports the same problem in Chrome, with the answer being that pressing Alt in Chrome enables the window menu, so the page loses focus and the keypress
event is not called. Something similar could be going on in Firefox, because if the Menu Bar is enabled in Firefox, pressing Alt opens the first item (File) of the Menu Bar. However, the answer to that question says that "keydown" does work.
I'm using Firefox 93.0 on Windows 10. I tried opening Firefox in Troubleshoot Mode (as I have Firefox configured extensively) but the problem persisted.
Any help would be appreciated!
Edit: It appears that this was caused by privacy.resistFingerprinting
in about:config
.
Upvotes: 4
Views: 591