Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Node.js binding for reading text inputs on Linux, such as barcode scanners
Node.js binding for reading text inputs on Linux, such as barcode scanners.
Features:
input_event
EVIOCGRAB
) opennpm install --save hid-input
npm install --save hid-input --build-from-source
Additional build dependencies are required on different platforms:
sudo apt install -y build-essential cmake ninja-build
brew install cmake ninja
import { createInput, listInputs } from 'hid-input';
const inputs = await listInputs();
console.log(inputs);
const reader = createInput(inputs[0].path);
reader.once('open', ()=>{
console.log('device opened');
});
reader.on('data', (input) => {
console.log(`- scanned: ${input}`);
});
listInputs()
Promise<InputDevice[]>
path
- string
Path to the devicename
- string
Human readable name of the deivceList HID input devices available on this machine.
createInput(path[, options])
path
- string
options
- Object
exclusive
- boolean
Whether to prevent the device from being opened by other processes before getting closedHidInputStream
Opens an input stream of device path
. Available devices along with paths can be retrieved with listInputs()
.
createMockInput(path)
path
- string
HidInputStream
Opens a mocking stream by listening on a newly created UNIX domain socket path
.
After the stream is open, you can emulate inputs with nc -U <path>
.
HidInputStream
fs.Readable
A readable stream in Object mode.
open
close
data
input
- string
Input read from the deviceclose()
Close the stream and release any underlying resources.
FAQs
Node.js binding for reading text inputs on Linux, such as barcode scanners
We found that hid-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.