key-event-to-string
key-event-to-string copied to clipboard
Use KeyboardEvent.key
KeyboardEvent.key
will make key-event-to-string's API much closer to the standard KeyboardEvent API.
References:
definitely it's a bug, e.g. on macos/chrome try pressing cmd+] - result is cmd+ý
It's definitely possible that this should be used. I created this in 2016 and barely wrote any JS since, so I'm not the best person to say. I'd welcome contributions though :)
I forked this repo and made it into a TypeScript library, and dropped deprecated keyCode
usage in favor of key
and code
.
It is available on npm:
{
"dependencies": {
"@rmkane/key-event-to-string": "0.2.3"
}
}
Let me know how it works.
Edit
I pushed version 0.4.x
which uses classes to encapsulate logic.
~~I pushed version 0.3.x
and changed the way config works. This makes the config more customizable and the aliases match the KeyboardEvent.key
values for easy mapping.~~
const options = {
keyAliases: {
Meta: '⌘',
Control: '⌃',
Alt: '⌥',
Shift: '⇧',
},
joinWith: '+',
}