Details
Description
In JS, "KeyboardEvent.code" is intended to reflect the physical location of a key, with name determined by its label on a QWERTY keyboard.
Bug: on Windows, in QtWebEngine, if you press right ctrl/alt, the resulting JS DOM "KeyboardEvent.code" value is left ctrl/alt. You can view keyboard events at W3C's Keyboard Event Viewer.
On Windows, WM_KEYDOWN delivers a 9-bit flag+scancode between 0x000 and 0x1ff, in bits 16-23 and 24. For some reason, when Chromium receives a WM_KEYDOWN message with an extended key (like right ctrl/alt and both win keys), it explicitly replaces the 0x100 bit with 0xe000 (presumably to match hardware scancodes). And DomCode expects extended keys to be in that format (link).
However, QtWebEngine's nativeKeyCodeForKeyEvent() fails to perform that transformation.
When QtWebEngine calls ui::KeycodeConverter::NativeKeycodeToDomCode(), the function fails to find the appropriate code for the native key. So "dom_code" is set to a value synthesized from "windows_key_code". Which is almost right, and works for pageup/pagedown... but it replaces right ctrl/alt with left ctrl/alt, and both Windows keys with left windows key...
In my fork, to fix this issue, I made `nativeKeyCodeForKeyEvent(const QKeyEvent *ev)` apply this transformation on Windows.
Link to my fork at https://github.com/nyanpasu64/qkeycode/blob/master/src/qkeycode/qkeycode.cpp#L145-L163. Permalink at https://github.com/nyanpasu64/qkeycode/blob/9480639/src/qkeycode/qkeycode.cpp#L145-L163 (link may break if I force push).