AltGr keydown/keyup events have keyCode=VK_MENU even under AltGr layouts |
||
Issue descriptionChrome Version: 57.0.2951.0 OS: ChromeOS What steps will reproduce the problem? (1) Configure ChromeOS for an AltGr layout. (2) Load content which listens for key events and uses keyCode values. What is the expected result? Expect that the AltGr key generates events with keyCode=VK_ALTGR (which Chrome uses VK_OEM_AX to represent). What happens instead? Events are generated with keyCode=VK_MENU, as would be the case under a non-AltGr layout. This may confuse some legacy content.
,
Jan 24 2017
We have lots of inconsistencies across the platforms with keyCode this isn't the first. I'd prefer to just leave keyCode as it is unless this is causing some major issues.
,
Jan 26 2017
Kevin do you have an opinion here?
,
Jan 26 2017
#3 Yes, but it's not printable. Chrome on Linux sends keyCode=VK_ALTGR (225), as does Firefox on Linux, so I think this counts as a bug. I see |NonPrintableXKeySymToDomKey()| maps |XKB_KEY_ISO_Level3_Shift| to |DomKey::ALT_GRAPH| and |kDomKeyToKeyboardCodeMap| maps |DomKey::ALT_GRAPH| to |VKEY_ALTGR|, so that's clearly the intent and I don't see anything obviously wrong at that layer. Using https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html (with 57.0.2927.0) I also see a discrepancy in the UI Events .key, which may be related: the keydown event has key='AltGraph' (right) but the keyup event has key='Alt' (wrong).
,
Feb 9 2017
Re #4: Yes, I filed issue 681362 for the keyup events' .key being wrong on ChromeOS and CC'd you there - looks like the XKB layout may be reporting the wrong KeySym when the ISO Level 3 Shift modifier is in effect.
,
Feb 9 2018
Re #5: It seems that all the keydown events in that case are AltGraph, and only the keyup is reported with |key| set to "Alt".
,
Feb 9 2018
Re #4: Looking at XkbKeyboardLayoutEngine::Lookup(), there are three possibilities that would mis-report AltGraph as VKEY_MENU. 1. There is no XKB keysym mapping, so we map based on DomCode. That would also cause |key| to be reported as Alt, though. 2. The reported keysym is ISO Level 3 Shift; the KeySym->DomKey mapping will report AltGraph, as we observe. We'll then try to map AltGraph to a KeyboardCode, which would produce VKEY_ALTGR. 3. We're succeeding in XKB mapping, but we don't recognize the KeySym, so we fall-through to the character-handling case, which causes us to base keyCode on a US English layout. But then we'd have an invalid |key| value, so... My guess is that there is some subtlety to the mapping at #2 that I'm missing. Can you send me a link to the source for the keymaps?
,
Feb 12 2018
#7 point 2 — mapping the keysym happens in XkbKeyboardLayoutEngine::Lookup(), starting at https://cs.chromium.org/chromium/src/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc?rcl=895f2a676702a889e3b75ad54db7c66bbde9345b&l=750 It looks to me that the keysym should indeed map to DomKey AltGraph (via NonPrintableXKeySymToDomKey() entry [1]) and then AltGraph maps to VK_ALTGR (via NonPrintableDomKeyToKeyboardCode() entry [2]). [1] https://cs.chromium.org/chromium/src/ui/events/keycodes/keyboard_code_conversion_xkb.cc?rcl=c1a6eba72be450170ba3947bd5504c7db20afcec&l=362 [2] https://cs.chromium.org/chromium/src/ui/events/keycodes/dom_us_layout_data.h?rcl=c1a6eba72be450170ba3947bd5504c7db20afcec&l=268
,
Feb 12 2018
Re #8: AltGraph is another key affected by the EventRewriter, so perhaps there is still something broken in there? |
||
►
Sign in to add a comment |
||
Comment 1 by w...@chromium.org
, Jan 24 2017