Getting a keyboard input into node-red

I'm trying to get a regular usb keyboard inputs into node-red on a windows 10 machine. I've tried keypress and that works nicely however it only works when you're on the terminal/CMD.

I tried node-red-contrib-usbhid, but get this error when trying to install (node-hid installed successfully)

I tried downlading the source code from github and pasting it into C:\Users\user\AppData\Roaming\npm\node_modules and C:\Users\user.node-red\node_modules

The nodes now appear on node-red but don't seem to work. The node getHIDdevices seems to work and gets the usb devices connected.

I put the VID and PID number into the HIDConfig node (just the numbers)
The HIDdevice node shows disconnected and the debug window has this error:
TypeError: Cannot read properties of undefined (reading 'on')

Why not install the node-red-contrib-usbhid from the pallet manager in NR? It's much easier.
Your running it now in the wrong directory, you need to install it in the nodered directory.
Most of the time C:\users\yourname\node-red



I tried it from the pallet manager but get the same error

What version of node.js are you using? Did you make sure to install the build tools?

v18.12.1, yep i made sure to tick the box when installing node.js

Sorry, out of ideas. You could try creating a mini node.js app that references node-hid and see if you can install it that way. If it still fails, at least you know that it is down to that library and you will need to find its github repo and raise an issue there.

makedir test
cd test
npm init -y
npm install node-hid

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.