key-listener

1.0.2 • Public • Published

key-listener

stable

A handler for adding listeners to key events without taking care of keys codes.

  var KeyListener = require('key-listener');
 
  var handler = new KeyListener();
  handler.addListener(document, 'a', function(){
    console.log("Hello World");
  });
  //This is going write Hello World when the letter 'a' is pressed.
 
  //If you really want to work with the codes and add your function as you like...
 
  handler.getKey('backspace'); // 8
  handler.getKey(16); // shift

Usage

NPM

Package Sidebar

Install

npm i key-listener

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3.84 kB

Total Files

4

Last publish

Collaborators

  • mbfassnacht