Re: [w3c/uievents] KeyboardEvent.key value definition does not match with existing browsers when modified by AltGraph key does not produce any characters (#252)

Actually, it was phrased that way as early as 2015. See https://www.w3.org/TR/2015/WD-uievents-20151215/#key-algorithm (notice Shift and AltGr are specifically excluded).

Returning `Unidentified` for nonprintable combos allows one to distinguish between AltGr combinations which produce a printable char on the current keyboard layout and those which are unbound.

To illustrate the problems with the current implementations, suppose we want to convert a straight apostrophe to a "curly" one in a text editor. To do this, we want to detect whenever the user types `'` (apostrophe), regardless of what key or key combo is necessary to do so in the user's keyboard layout.

Now suppose we get a keydown event with `.key == "'"` (apostrophe) and AltGr pressed. What does this mean?

1. The user pressed an AltGr combination which types `'` on the current keyboard layout (e.g. Alt+G or Alt+Shift+2)
or
2. The user pressed AltGr+' (AltGr with a key whose unmodified function is to type `'`) and that combination is unbound.

Which is it? With the current behavior, we can't tell. But we only want to react if it's (1).

Anticipating possible objections: listening for `beforeinput` is not a substitute, because we only want to react to keyboard input, not other operations that might insert characters.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/uievents/issues/252#issuecomment-558593337

Received on Tuesday, 26 November 2019 11:47:06 UTC