shortcut
v0.0.4
Published
Subscribe handlers to keyboard shortcuts
Downloads
31
Readme
Shortcut
Assign functions to keypress
events
Example
var shortcut = require('shortcut')(process.stdin)
process.stdin.setRawMode(true)
process.stdin.resume()
shortcut('ctrl+c', process.exit)
shortcut('alt+a, shift+a, ctrl+a', function() { console.log('awesome') })
shortcut('meta+q', console.log.bind(null, 'queue', '...so meta'))
Installation
npm install shortcut
Usage
shortcut(shortcut, fn)
'shortcut': A combination of Modifiers
joined by +
and terminated with
a single key. You can join shortcuts with a comma ,
to assign multiple to
one function.
fn(event, handler): fn will be called with the keypress event and the handler
Modifiers
shift
:⇧
,shift
ctrl
:^
,ctrl
,control
meta
:⌥
,meta
,alt
,option
Inspiration
This module is heavily inspired by Thomas Fuchs' keymaster library.
License
MIT