0.0.4 • Published 13 years ago
shortcut v0.0.4
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 shortcutUsage
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:⇧,shiftctrl:^,ctrl,controlmeta:⌥,meta,alt,option
Inspiration
This module is heavily inspired by Thomas Fuchs' keymaster library.
License
MIT