Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

miguelmota/global-keypress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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