Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

simple-keyboard-handler

0.3.0 • Public • Published

Simple Keyboard Handler

Build Status Coverage Status Dependency Status

A singleton module to catch keyboard events and then fire callbacks.

If you require this in your project it will automatically be initalized and add an eventListener.

Usage

var keyBoardHandler = require( "simple-keyboard-handler" );
 
// Maps SHIFT+K to the passed function
keyBoardHandler.addShortcut( {
    keyCode: 75 // keycode for 'k'
    ctrl: false // defaults to false
    shift: true // defaults to false
    alt: false // defaults to false
}, function () {
    console.log( "This is my callback." );
} );

If you don't know a keycode, checkout keycode.info

Install

npm i simple-keyboard-handler

DownloadsWeekly Downloads

2

Version

0.3.0

License

MIT

Last publish

Collaborators

  • avatar