node-dev-input-reader
Read input from /dev/input/* on a linux Host.
Dual Stack package ESM + CJS, should work in deno
Feature
- Detect double press / click
- Detect long press / click
- Detect Key combinaison
- Support hardware disconnect / reconnect.
- Can work from /dev/input/by-id/ and /dev/input/by-path/
- Detect device type (event/joystick/mouse)
- Writen in Typescript
Usage
With raw events:
const reader = new DevInputReader('event0');
reader.on('error', console.error)
.on("keyup", (data) => console.log('keyup:', data))
.on("keypress", (data) => console.log('keypress:', data));
With syntetic events (recommanded):
const reader = new DevInputReader('event0'm { retryInterval: 10000});
reader.on('error', console.error)
.on("key", (data) => console.log('key:', data))
.on("error", (data) => console.log('an error occure:', data))
With syntetic events with double/long click detection (if needed):
const reader = new DevInputReader('event0', { retryInterval: 10000, longPress: 5000, doublePress: 300 });
reader.on('error', console.error)
.on("simple", (data) => console.log('simple press:', data))
.on("double", (data) => console.log('double press:', data))
.on("long", (data) => console.log('long press:', data))
FAQ
Why a new Module ?
There is a lot of existing module that can deal with input:
Relative package: