key-event-to-string icon indicating copy to clipboard operation
key-event-to-string copied to clipboard

Use KeyboardEvent.key

Open EvgenyOrekhov opened this issue 3 years ago • 3 comments

KeyboardEvent.key will make key-event-to-string's API much closer to the standard KeyboardEvent API.

References:

EvgenyOrekhov avatar Jul 26 '20 14:07 EvgenyOrekhov

definitely it's a bug, e.g. on macos/chrome try pressing cmd+] - result is cmd+ý

cinan avatar Apr 12 '21 14:04 cinan

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 :)

florian avatar Apr 12 '21 19:04 florian

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: '+',
}

rmkane avatar Feb 14 '24 19:02 rmkane