[UI Events-code] Keyboard event has event.code Backquote and IntlBackslash swapped on macOS with 102/105 ISO keyboard
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
People
(Reporter: mathieulj, Unassigned, NeedInfo)
References
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0
Steps to reproduce:
window.onkeydown = (e) => console.log("code:", e.code, "key:", e.key);
With an ISO 102/105 keyboard on macOS:
- Press the key above tab and immediately to the left of the 1 (/ if using the french Canadian locale)
- Press the key immediately to the right of the left shift key (ù if using the french Canadian locale)
With an ANSI 101/104 keyboard still on macOS:
3. Press the key above tab and immediately to the left of the 1 (` if using the Canada English locale)
Actual results:
- code: Backquote key: /
- code: IntlBackslash key: ù
- code: Backquote key: ù
Expected results:
- code: IntlBackslash key: /
- code: Backquote key: ù
- code: Backquote key: ù
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Cocoa' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•2 years ago
|
||
Could you confirm a couple of things:
- Does this reproduce in Safari or Chrome?
- Has this worked on previous versions of Firefox?
Sure thing:
- Safari works as expected. Chrome has the same issue, there is a bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=1296783
- I'm not sure when it was working before. I've just starting using the event code on a project that made this stand out to me but I did stumble into a closed issue since I created this bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1263302. It would seem to hint that this has been fixed before and may have regressed since but I don't know when.
Comment 4•2 years ago
|
||
Would you be able to run Mozregression to see when this issue was (re-)introduced?
I've run Mozregression and narrowed it down to:
> mozregression --bad 2017-03-01 --good 2017-02-28
0:03.50 INFO: Got as far as we can go bisecting nightlies...
0:03.50 INFO: Last good revision: 1bc2ad020aee2830e0a7941f10958dbec108c254 (2017-02-28)
0:03.50 INFO: First bad revision: 34c6c2f302e7b48e3ad2cec575cbd34d423a9d32 (2017-03-01)
0:03.50 INFO: Pushlog:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=1bc2ad020aee2830e0a7941f10958dbec108c254&tochange=34c6c2f302e7b48e3ad2cec575cbd34d423a9d32
This is very interesting because that range includes the "fix" addressing https://bugzilla.mozilla.org/show_bug.cgi?id=1263302. Re-reading that issue now made me realise they were reporting the reverse of what I am seeing. The were seeing the behaviour I would expect and concluded it was a bug.
macOS swaps the IntlBackslash and Backquote keys when the events are coming from an ISO keyboard. With the current state of the code base, pressing the ` key on my ANSI keyboard produces event.key
=== ` and event.code
=== Backquote whereas pressing the ` key on my ISO keyboard produces event.key
=== ` and event.code
=== IntlBackslash. Surely both these standard apple keyboards should produce the same event.code
to match the typed out character?
Comment 6•2 years ago
|
||
Masayuki-san, could you weigh in here? See comment 5. Thank you!
Comment 7•2 years ago
|
||
Sounds like that macOS changed the behavior so that I guess that we need to check older macOS behavior too.
Comment 8•2 years ago
|
||
According to the timestamp, at least OS X 10.11 El Capitan and macOS Sierra 10.12 had the bug.
Comment 9•2 years ago
|
||
Looks like that the expected result is wrong for 102/105 keyboard layout. The key left of Digit1
should be Backquote
and the key right of ShiftLeft
should be IntlBackslash
. Could you check the relation of STR, actual results and expected results in comment 0?
Comment 10•2 years ago
|
||
When I connect JIS 106 (for PC)/ANSI 101 keyboard (Apple)/102 keyboard (for PC) to macOS Monterey whose active keyboard layout is Canadian French CSA, I get same result. The key left of Digit1
is Backquote
.
Comment 11•2 years ago
|
||
Ah, I use Intel Mac. If it's related to keyboard driver of macOS, the CPU architecture may change the behavior.
Updated•2 years ago
|
Description
•