# Getting a keyboard input into node-red

**URL:** <https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951>\
**Category:** General\
**Created:** [21 November 2022 02:46 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951 "2022-11-21T02:46:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix\_Cheah](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@Felix\_Cheah](https://discourse.nodered.org/u/Felix_Cheah)\
**Post date:** [21 November 2022 02:46 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/1 "2022-11-21T02:46:27Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/7/074a4ffb695bd0fea2111d57efddf64c3a942a92.png)

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/6538dbc3e47c36bf8a04b33a335c6304de5b463d.png)

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')

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [21 November 2022 08:53 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/2 "2022-11-21T08:53:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 November 2022 11:24 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/3 "2022-11-21T11:24:58Z")

</div>

Correction:

```auto
C:\users\<yourid>\.node-red

```

---

<div class="post-metadata">

**Author:** ![Felix\_Cheah](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@Felix\_Cheah](https://discourse.nodered.org/u/Felix_Cheah)\
**Post date:** [21 November 2022 19:02 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/4 "2022-11-21T19:02:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 November 2022 21:15 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/5 "2022-11-21T21:15:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Felix\_Cheah](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@Felix\_Cheah](https://discourse.nodered.org/u/Felix_Cheah)\
**Post date:** [21 November 2022 21:26 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/6 "2022-11-21T21:26:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 November 2022 21:33 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/7 "2022-11-21T21:33:25Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 January 2023 21:34 UTC](https://discourse.nodered.org/t/getting-a-keyboard-input-into-node-red/70951/8 "2023-01-20T21:34:23Z")

</div>

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