Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

linux-input-device

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linux-input-device

A simple library to receive events in NodeJS when input events occur

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by36.36%
Maintainers
1
Weekly downloads
 
Created
Source

node-linux-input-device

Native addon to communicate with linux input devices.

Installation

Install with npm:

$ npm install linux-input-device

API

new LinuxInputListener( String devicePath )

Creates a new LinuxInputListener instance.

  • path A path to a linux input device

Event: state( Boolean state, Number keyCode, String keyKind )

Fired when a key state changes or when a key is queried.

  • state True if the key is pressed, false otherwise
  • keyCode Code of the key whose state has changed
  • keyKind Category of the key.

String[] LinuxInputListener.KEY_KINDS

Array containing all supported key kinds, like EV_KEY, EV_SW, or EV_LED.

LinuxInputListener.query( String keyKind, Number keyCode )

Query the current key. Also fires the state event.

  • keyCode Code of the key whose state to query
  • keyKind Category of the key. Must be one of the strings in LinuxInputListener.KEY_KINDS

LinuxInputListener.close([Function callback()])

Closes the current device and invoke callback when the device is closed.

  • callback() [optional] A callback function

Examples

var LinuxInputListener = require('linux-input-device');

var SW_LID = 0x00;

var input = new LinuxInputListener('/dev/input/event0');

input.on('state', function(value, key, kind) {
    console.log('State is now:', value, 'for key', key, 'of kind', kind);
});

input.on('error', console.error);

//start by querying for the initial state.
input.on('open' => input.query('EV_SW', SW_LID));

Keywords

FAQs

Package last updated on 20 Nov 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc