New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shortcut

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shortcut

Subscribe handlers to keyboard shortcuts

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Shortcut

Assign functions to keypress events

Usage

var shortcut = require('../shortcut')(process.stdin)

process.stdin.setRawMode(true)
process.stdin.resume()

// shortcut assignment
shortcut('ctrl+c', process.exit)

// multiple shortcuts bound to one function
shortcut('alt+a, shift+a, ctrl+a', function() { 
  console.log('awesome') 
})

// get event and handler data
shortcut('b, ⇧+b, ^+b, ⌥+b', function(e, handler) {
  console.log(handler.shortcut+': fired!')
})

Installation

npm install shortcut

require('shortcut')(ReadableStream)

If the ReadableStream is not emiting keypress events then the stream will be passed into keypress

Returns the shortcut library listening to ReadableStream

shortcut(string, fn)

  • string: 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: Will be called with the keypress event and the shortcut handler

Modifiers

  • shift: , shift
  • ctrl : ^, ctrl, control
  • meta : , meta, alt, option

Inspiration

This module is heavily inspired by Thomas Fuchs' keymaster library.

License

MIT

Keywords

key

FAQs

Package last updated on 15 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts