node-dev-input-reader
Read input from /dev/input/* on a linux Host.
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 event:
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:
dev-input Looks nice in typescript, but no docs, only used by hist owner.
linux-keyboard-catcher highly Keyboard oriented, simple interface.
node-keylogger very low level + forck from node-keyboard + contains bug..
raw-keyboard very low level + use C code.
Relative package:
linux-key-info Key mapping for keyboard, I may integrate it on day.