Closed Bug 809410 Opened 12 years ago Closed 4 years ago

onkeydown not matched by onkeyup when AltGr is pressed on Windows

Categories

(Core :: DOM: Events, defect, P3)

16 Branch
x86_64
Windows 7
defect

Tracking

()

RESOLVED DUPLICATE of bug 1435717

People

(Reporter: mozilla, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
Build ID: 20121024073032

Steps to reproduce:

1. register a handler for the window.onkeyup and window.onkeydown events.
For example, 
>    window.onkeydown = function(ev) { console.info("key down: ", ev.which); }
>    window.onkeyup = function(ev) { console.info("key up: ", ev.which); }

2. press the AltGr key (present on many non-US keyboard layouts, but I have only tested with Danish keyboard layout)

It seems AltGr is emulated by sending both a CTRL and ALT keypress. However, when the key is released, an onkeyup event is only fired for the CTRL key.

This leads some web pages (such as NoVNC) to believe that ALT is still pressed, modifying subsequent keyboard input.

I have reproduced the problem on a Windows 7 machine with Danish keyboard layout, in Firefox 13 though 16.


Actual results:

The following is printed in the web console:

>    key down:  17
>    key down:  18
>    key up:  17

no onkeyup event is fired for the key code 18.


Expected results:

A onkeyup event should have been triggered for both:

>    key down:  17
>    key down:  18
>    key up:  17
>    key up:  18
Also in FF Aurora 18.0a2 (2012-11-01)

There an anomaly with the event.location too:-

keydown: keyCode:17 location: 1

keydown: keyCode:18 location: 2

keyup: keyCode:17 location: 1
A related issue:

If you press alt + a, you get:
key down: 18 (alt press)
key down: 65 ('a' press)
key up: 64 (a release)

But alt never gets a keyup event.
@Masayuki Nakano: any progress on this issue?
It seems that first this bug had been fixed probably by this change: https://hg.mozilla.org/mozilla-central/rev/66b99572ab26#l3.12 which was meant as a part of the fix for the bug 708936 and then has been reintroduced recently because I can reproduce it. I have not got every version of Firefox so I can only say that:

- Firefox 52.x which has been released in March 2017 does not have this bug (Windows XP),
- Firefox 56.x has this bug (modern Windows),
- Firefox 57.x including the most recent version has this bug (modern Windows, as well).

So the bug has been reintroduced somewhere between March (or slightly before) and September 2017.

How to reproduce:

- Open a testing web page, for example http://unixpapa.com/js/testkey.html
- Check the "keydown" and "keyup" checkboxes, "modifiers" should be fine as well,
- Press and release AltGr (right Alt).

Result: the log window displays the events:
- keydown for keyCode 17 (Ctrl),
- keydown for keyCode 18 (Alt),
- keyup for keyCode 17 (Ctrl),
- nothing more.

Expected result:
- Same as above but keyup for keyCode 18 (Alt) should be received and logged as the last event.

The key event sequence may depend on the keyboard layout. AFAIK all (most?) international (non-US English) keyboard layouts in Windows generate Alt+Ctrl sequence when AltGr (right Alt) is pressed. I have reproduced the problem with the Polish keyboard layout.

This bug is in Windows only, I have also tested Firefox on OS X and Linux and they support the right Alt key differently.
Priority: -- → P3
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.