Open masayuki-nakano opened 4 years ago
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?
'
on the current keyboard layout (e.g. Alt+G or Alt+Shift+2)
or'
) 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.
https://w3c.github.io/uievents-key/#h-clipboard-read
With this definition, if
AltGraph
+f
does not reproduce character, the key value becomesUnidentified
.IIRC, with the older draft, the
key
value should be computed withoutAltGraph
key in this case. Therefore, any browsers behave so (on Firefox, probably due to a bug, characters withoutAltGraph
is inputted, though).Additionally, even if this is false, the
key
value should be empty string rather thanUnidentified
because of not a function key.