Shortcut
Assign functions to keypress
eventsExample
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 ofModifiers
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