2.0.5 • Published 10 months ago

keycode-to-codes v2.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
10 months ago

npm

keycode-to-codes

Library that returns a list of possible KeyboardEvent codes based the input keyCode. Useful for replacing a missing KeyboardEvent.code property.

Example: 13 -> ["Enter", "NumpadEnter"] \ 32 -> ["Space"] \ 97 -> ["KeyA"]

Installation

Add the script to your project through a package manager:

$ npm i keycode-to-codes

or

$ yarn add keycode-to-codes

Alternatively you can also import the script found in the releases section on GitHub directly. If you choose this option you won't need to use imports going forward - everything will all be available to you automatically.

<script src="keycode-to-codes.min.js"></script>

Or include through a public CDN:

<script src="https://unpkg.com/keycode-to-codes@2/dist/keycode-to-codes.min.js"></script>

Usage Example

  import keyCodeToCodes from 'keycode-to-codes';
  // OR
  const keyCodeToCodes = require('keycode-to-codes');

  window.addEventListener('keypress', (event) => {
    const codes = keyCodeToCodes(event.keyCode);
  });
2.0.5

10 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago