@vaalentin/keycodes

1.0.1 • Public • Published

@vaalentin/keycodes

Javascript keycodes as an enum.

Installation

$ npm install --save @vaalentin/keycodes

Usage

The whole enum can be imported at once:

import * as Keys from '@vaalentin/keycodes';

document.addEventListener('keydown', e => {
  if(e.keyCode === Keys.A) {
    // a is pressed
  }
});

Or just specific keycodes:

import { A, B, C } from '@vaalentin/keycodes';

document.addEventListener('keydown', e => {
  if(e.keyCode === A) {
    // a is pressed
  }
});

License

MIT, see LICENSE.md for more details.

Readme

Keywords

Package Sidebar

Install

npm i @vaalentin/keycodes

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • vaalentin