miguelmota / global-keypress

Global key press event emitter.

Home Page:https://github.com/miguelmota/global-keypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Global key press event emitter.

https://github.com/miguelmota/global-keypress

License:MIT License


Languages

Language:C 75.8%Language:JavaScript 19.6%Language:Shell 2.6%Language:Makefile 2.0%