Reputation: 49
I have an application with shortcuts. Shortcuts are defined by the keys that need to be pressed to trigger them and the respective action that should happen.
When pressing Ctrl + Alt + E on the keyboard, the triggered keydown KeyboardEvent.key
value is not "e" but "€", because Ctrl + Alt + E also is the combination for the € char.
So I can't define the shortcut as Ctrl + Alt + E.
Should I define it as Ctrl + Alt + € instead? This seems somewhat hacky to me, because pressing Ctrl + Alt + E won't result in € on all machines.
I thought about using the KeyboardEvent.code
instead of KeyboardEvent.key
. But the way I understood it, the KeyboardEvent.code
is dependent on the keyboard layout. It should always be the letter "e" though.
Any idea how I can still define the shortcut as Ctrl + Alt + E? (it is a graph drawing application, and "e" stands for edge, using any other letter would be unfortunate).
Upvotes: 1
Views: 420
Reputation: 221
it does work but you still have to cumulate to the other conditions for non-OSX users...
if (event.altKey && e.key === "€" || event.altKey && e.key === "e"){
doSomeThing()
}
Upvotes: -1