hotkeys-js icon indicating copy to clipboard operation
hotkeys-js copied to clipboard

when alt/option (or even shift) key is used, the event.key is not what it should be

Open vesper8 opened this issue 4 years ago • 1 comments

I noticed if you press the p then the event.key is p

I noticed if you press shift+p then the event.key is P

and if you press alt+p then the event.key is π

In all 3 cases the event.code is KeyP and the event.keyCode is 80

I would expect that the event.key should be simply p in all 3 cases above. I would like to be able to alert('you have pressed __') to print out alt-p, but currently I cannot achieve this without doing some additional processing, converting somehow KeyP or 80 to p

The actual key pressed, in this case p, should be readily available to hotkeys even when the modifier keys are used

vesper8 avatar Mar 24 '20 21:03 vesper8

I found a workaround which is to use String.fromCharCode(event.keyCode) instead of event.key

vesper8 avatar Mar 24 '20 22:03 vesper8