Gecko's KeyboardEvent.keyCode value for each printable key is mapped from an ASCII character which is produced by the key with active keyboard layout or alternative ASCII capable keyboard layout if active keyboard layout is not ASCII capable. However, we decided not to use ASCII punctuation character of alternative ASCII capable keyboard layout when we compute keyCode value of punctuation keys ("Backquote", "Equal", "Minus", "LeftBracket", "RightBracket", "Semicolon", "Quote", "Comma", "Period", "Slash", "Backslash", "IntlBackslash", "IntlYen" and "IntlRo" keys of KeyboardEvent.code) since we tried to avoid mapping same keyCode value to 2 or more keys.

However, a lot of web applications still use KeyboardEvent.keyCode even in these days and they can support only their main target's keyboard layout. Therefore, if users whose active keyboard layout produces only Unicode character with punctuation keys like Russian, such keys are not available on web applications which supports only ASCII capable keyboard layout (i.e., such users need to switch active keyboard layout to alternative ASCII capable keyboard layout only while they want to use keyboard on such web applications).

For making this issue a little better, Firefox 60 will set such keys' keyCode value to same keyCode value as alternative ASCII capable keyboard layout only when Firefox 59 and earlier set the value to 0.

So, please not that this behavior change does NOT try to solve compatibility with the other browsers because it's impossible without breaking compatibility with Firefox-aware web applications. This change tries to improve compatibility with web applications which supports Firefox but assumes users use ASCII capable keyboard layout.

If web applications hit this issue, they should use KeyboardEvent.code in most cases because they don't check each keyboard layout's key meaning actually.

The bug to change this behavior:
https://bugzilla.mozilla.org/show_bug.cgi?id=1036008

Document in MSDN:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#keyCode_of_punctuation_keys_on_some_keyboard_layout

--
Masayuki Nakano <masay...@d-toybox.com>
Software Engineer, Mozilla
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to