npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hidstream

v2.1.0

Published

Streaming HID events in Node.js

Downloads

25

Readme

HIDSTREAM

Streaming HID Events in Node.js

Wraps node-hid with several parsers for common HID devices, specifically, keyboard-like devices.

Data parsers are available for:

  • raw: passes the data as reported by node-hid.
  • keyboard: for keyboard-like devices.
  • newline: for keyboard-like devices where events are emitted on new-lines. (e.g. many barcode scanners, etc.)

Example:

var hid = require('hidstream');
var dev = new hid.device('0001:001:00', { parser : hid.parser.keyboard });

dev.on("data", function(dat) {
    console.log(dat); // easily consumed data format!
});

Sample HID Data Events for the parser:

The user has pressed Ctrl + Alt + Del

{
    modifiers : {
        l_shift :   false,
        l_control : true,
        l_alt :     true,
        l_meta :    false,
        r_ctrl :    false,
        r_shift :   false,
        r_alt :     false,
        r_meta :    false
    },
    keyCodes : [
        76
    ],
    keyChars : [],
    errorStatus : false
}

The user has pressed w, a, s & d (simultaneously (why? I don't know))

{
    modifiers : {
        l_shift :   false,
        l_control : false,
        l_alt :     false,
        l_meta :    false,
        r_ctrl :    false,
        r_shift :   false,
        r_alt :     false,
        r_meta :    false
    },
    keyCodes : [
        26, 4, 22, 7
    ],
    charCodes : [
        'w', 'a', 's', 'd'
    ],
    errorStatus: false
}

Convenience Methods

The data packet has additional convenience methods, shift(), control(), alt(), and meta() which return true if either the left or right of each key is pressed. The function mod() returns true if any of the modifier keys is pressed.

Additionally, empty() returns true if there is no modifier or key currently down.

Status

Right now, hidstream is only parsing keyboard events, and has no awareness of HID feature reports.

After keyboard events are being parsed properly (and fully), I will add support for feature reports and other devices such as mice.

Contributions

Significant refactor contributed by @kubat