0.0.4 • Published 11 years ago

shortcut v0.0.4

Weekly downloads
8
License
-
Repository
github
Last release
11 years ago

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

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

12 years ago

0.0.1

12 years ago