Open Bug 1934679 Opened 1 year ago Updated 1 year ago

Consider align the keycode for '=' in both English and German keyboard.

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

People

(Reporter: sefeng211, Unassigned)

References

(Depends on 1 open bug)

Details

For the '-' key, we dispatch the same keycode, 173.

But why do we dispatch a different one for the '=' key? It's 61 in English keyboard, but 171 in German keyboard.

This may also fix bug 1895725.

See Also: → 1895725

Which platform? macOS?

Basically, we use ASCII char which is introduced without Shift or with Shift if a Unicode character is introduced without Shift. Then, compute the keycode from the ASCII char.

The keyCode value is unfortunately an arbitrary number, not a meaningful number and the values are not compatible if the active keyboard layout is not for only ASCII char input, especially on non-Windows platforms. So, first, web apps should use .key or .code instead. Otherwise, they still need to use .keyCode, they need to make global constants and use them on each browser. Once we change the value, such web apps may be broken, so, I think that we should not touch .keyCode anymore.

The webcompat bug for Google doc was for Windows.

Yeah, I totally agree that web sites shouldn't rely on keycode, and changing it may break sites. However, I do want to point out that I think there's a tradeoff here, maybe at some point we should align with Chrome if that will bring us better web-compat support.

I think it would be valuable to be able have the behaviour configurable by origin. That way at least when we spoof the user agent as Chrome for webcompat reasons we can make sure our keycode behaviour matches Chrome.

Google Docs suggests S2-ish, but since this does not appear to be about editing functionality on Google Docs and there's other UI for reaching the function, setting S3.

Severity: -- → S3

Yeah, I thought that if we add Window.requestCompatKeyCode() and once it's called, KeyboardEvent.KeyCode() can compute similar keyCode value to Chromium.

We can know how Chromium maps keyCode values on non-Windows platform:

However, the ideal fix this issue is, we should suggest a new KeyboardEvent attribute which returns a string value which represents the key what Chromium's .keyCode value means with clear definition.

You need to log in before you can comment on or make changes to this bug.