Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use KeyboardEvent.key #2

Open
EvgenyOrekhov opened this issue Jul 26, 2020 · 3 comments
Open

Use KeyboardEvent.key #2

EvgenyOrekhov opened this issue Jul 26, 2020 · 3 comments

Comments

@EvgenyOrekhov
Copy link

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

References:

@cinan
Copy link

cinan commented Apr 12, 2021

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

@florian
Copy link
Owner

florian commented Apr 12, 2021

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

@rmkane
Copy link

rmkane commented Feb 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants