1.1.0 • Published 7 years ago

delightful-keycodes v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Usage

const dk = require('delightful-keycodes');

let key = dk(99);
// key => 'c'

delightful-keycodes can take multiple types of values and automatically convert the keyCode to the correct character.

Example

Plain Ascii keyCode
let keyCode = 99;

dk(keyCode) // => 'c'
Browser key press events
let keyPressEvent = {
  keyCode = 99
}

dk(keyPressEvent) // => 'c'
Events with key property
let keyPressEvent2 = {
  key: 'f',
  keyCode = 99
}

dk(keyPressEvent2) // => 'f'

Chrome automatically converts the keyCode for you and provides it in the key property. This is showing that delightful-keycodes won't convert the keyCode if a key is already provided.

This feature exists only because Safari doesn't convert the keyCode for you so you can throw the event into delightful-keycodes regardless of the browser and it's smart enough to decide whether it needs to convert or not.

Planned Features

  • Ability to take a character as an argument and automatically convert it to the proper keyCode.
1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago