global-keypress

0.0.8 • Public • Published

global-keypress

Global key press event emitter

NOTE: requires sudo privileges. GUI prompt will appear asking for sudo access if not running as root.

Supports Mac OS X and Linux.

Install

npm install global-keypress

Development

compile native module

npm run compile

Usage

const GK = require('global-keypress');
 
// instantiate
const gk = new GK();
 
// launch keypress daemon process
gk.start();
 
// emitted events by process
gk.on('press', data => {
  console.log(data);
 
  // example output
  /*
  { data: 'a' }
  { data: 'b' }
  { data: '1' }
  { data: '2' }
  { data: '<RShift>' }
  { data: 'A' }
  { data: 'B' }
  { data: '!' }
  { data: '@' }
  { data: '[released <RShift>]' }
  { data: '<Enter>' }
  */
});
 
// process error
gk.on('error', error => {
  console.error(error);
});
 
// process closed
gk.on('close', () => {
  console.log('closed');
});
 
// manual stop
gk.stop();

Resources

License

MIT

Package Sidebar

Install

npm i global-keypress

Weekly Downloads

19

Version

0.0.8

License

MIT

Last publish

Collaborators

  • miguelmota