Open Bug 1784404 Opened 2 years ago Updated 2 years ago

Modifier keys (alt, shift, ctrl) do not trigger "keydown", "keyup" event

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

Firefox 103
defect

Tracking

()

UNCONFIRMED

People

(Reporter: a1234686809, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

Steps to reproduce:

Run in the console:
window.addEventListener("keydown" , e=>{ console.log(e) })
Press Alt or Ctrl or Shift
-> no keydown events are fired
Press Alt+E (E or any other key)
-> e.altKey is false. It should be true.

Actual results:

Modifier keys do not trigger key events.
"event.altKey" is always reported as false.

Expected results:

Modifier keys must trigger key events.
event.altKey must be true when Alt is pressed.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: UI Events & Focus Handling' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: UI Events & Focus Handling
Product: Firefox → Core

I can't reproduce the issue. For me, pressing modifiers successfully generated key events and Alt+E has altKey: true.

Can you test it again with a new profile and see if it still reproduces?

Flags: needinfo?(a1234686809)

For me altKey is only reported in a private window when pressing Alt+Key. Strangely. It is not reported in normal windows, even though the event is logged as "keydown Alt", and even with all extensions disabled. On Alt+Shift+Key, both shiftKey and altKey are false. shiftKey is true when Alt is not involved: Ctrl+Shift+Key -> ctrlKey:true, shiftKey:true.

Modifier key keydown/keyup events, when they are pressed without a non-modifier key, are still not fired in either window. Pressing Ctrl does not fire any key events. If UIs want to show a tooltip when Shift is down they can do that in Chrome, but they cannot do that in Firefox.

Flags: needinfo?(a1234686809)

(In reply to a1234686809 from comment #3)
Correction:
When pressing Alt+E the altKey is always reported as false, even in private windows. It is only reported as true in a blank page about:newtab and about:privatebrowsing. I had tested it on a blank window in the previous post. When testing it on any loaded page, altKey is always reported as false.

Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.