I would like to implement hotkeys in a web application using the .code
property of the received keyboard events, as those seem to be the correct way to produce layout-independent bindings. The only issue is that while I'm completely fine with ignoring the produced symbols under the hood, I would still like to show the user the keyboard hints that they need to press adjusted to their own layouts.
For examply I would like to keep the shortcut for Undo to be the the left shift and the key right next to it ("KeyZ", keycode 0x002C
), but on for example the Hungarian layout (see below), that key produces the symbol Y
, so I would like to show the user the following hint: "Undo (Ctrl + Y)".
Is that achievable in some way? I tried searching for a browser API, that would map modifiers and keycodes to symbols on the currently active layout, but couldn't find any, and I couldn't come up with any possible workaround either.