项目作者: miguelmota

项目描述 :
Global key press event emitter.
高级语言: C
项目地址: git://github.com/miguelmota/global-keypress.git
创建时间: 2017-05-10T19:28:15Z
项目社区:https://github.com/miguelmota/global-keypress

开源协议:MIT License

下载


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

  1. npm install global-keypress

Development

compile native module

  1. npm run compile

Usage

  1. const GK = require('global-keypress');
  2. // instantiate
  3. const gk = new GK();
  4. // launch keypress daemon process
  5. gk.start();
  6. // emitted events by process
  7. gk.on('press', data => {
  8. console.log(data);
  9. // example output
  10. /*
  11. { data: 'a' }
  12. { data: 'b' }
  13. { data: '1' }
  14. { data: '2' }
  15. { data: '<RShift>' }
  16. { data: 'A' }
  17. { data: 'B' }
  18. { data: '!' }
  19. { data: '@' }
  20. { data: '[released <RShift>]' }
  21. { data: '<Enter>' }
  22. */
  23. });
  24. // process error
  25. gk.on('error', error => {
  26. console.error(error);
  27. });
  28. // process closed
  29. gk.on('close', () => {
  30. console.log('closed');
  31. });
  32. // manual stop
  33. gk.stop();

Resources

!-- https://bitbucket.org/cabalistic/ogredeps/src/a623a62ae85c/src/ois/src/?at=default http://stackoverflow.com/questions/10734349/simulate-keypress-for-system-wide-hotkeys https://github.com/depp/keycode --

License

MIT