These are my notes and tests about keyboard events in web browsers.
The current browser recommendations are to use KeyboardEvent.key
[1] to match the current keyboard layout, and KeyboardEvent.code
[2] to match the physical key location. Try using Dvorak or a non-US keyboard layout to see how the key
will change, but the code
will stay the same for the same physical key.
I don’t think there’s an event to be notified when the keyboard layout changes.
Source: keyboard.js