Short version: Is the NodeMCU capable of key injection in the same way that an Arduino Teensy can be programmed with Duckuino script to function as a HID?

Long version: Recently, my 7+ year old iMac suddenly stopped working and now I am unable to boot into the Mac which is a right pain. Even more of a pain is that due to the fact that the iMac has a wireless keyboard as opposed to a USB meaning that I am unable to boot into Single User mode, recovery mode, safe boot etc. This is a pain as I am currently stuck with an iMac in an unsuccessful boot loop. I understand that the best option would be to buy a USB keyboard and use this separately; however, it turns out that one of my friends has a spare NodeMCU and said he's willing to lend it to me as he is pretty sure that the Duckuino script will work on it meaning that I could use the NodeMCU as a sort of impromptu keyboard to hold down the shift key on boot, effectively removing the need for me to buy and wait for a new USB keyboard.

I had found this video here on YouTube which explains the process of turning an Arduino into a "USB Rubber Ducky" but there is no mention of this working with a NodeMCU. Assuming that I have the ESP8266 addon for the Arduino IDE and was able to put the Duckuino script onto the NodeMCU, would the NodeMCU function as intended with the Duckuino script or is the NodeMCU hardware such that this would be impossible?

Thank you for any assistance,

Kind regards, John

P.s. This is what my NodeMCU looks like:

enter image description here

  • 2
    No, you can't. You need a USB capable MCU. The ESP8266 is not.
    – Majenko
    Jul 20, 2018 at 12:01
  • @Majenko Thank you for your response; so I would need something like the Teensy etc?
    – Tom
    Jul 20, 2018 at 12:07
  • 1
    Yes, or an Arduino Micro, or other ATMega32U4 based Arduino. Or one of the direct-USB connected chipKIT boards, like a Fubarino Mini, etc.
    – Majenko
    Jul 20, 2018 at 12:09
  • lend an USB keyboard :-)
    – Juraj
    Jul 20, 2018 at 12:10
  • 1
    if you live near a goodwill or salvation army, you can get a (used) usb kb for about $2...
    – dandavis
    Jul 20, 2018 at 16:55

1 Answer 1


No, you can't use a NodeMCU for this.

To emulate a USB keyboard you have to have a device with a main MCU on it which is directly connected to USB. The ESP8266 on the NodeMCU is not a USB-capable MCU, and so it uses a USB to UART bridge chip to connect the ESP8266 to the USB of your computer.

You can't program that bridge chip, so you can't make it anything other than a serial port.

Common devices that are directly USB connected and can emulate a keyboard include:

  • Arduino Micro
  • Teensy 3.X
  • Fubarino Mini / SD
  • Arduino Leonardo
  • chipKIT Lenny

And there are many more.

For 8-bit Arduino boards you need to look at the MCU it uses. If it's an ATMega32U4 as the main MCU then you can program it to be a keyboard.

Addendum: There are ways of making non-USB boards work as a keyboard. For ATMega328P based Arduinos and similar that use an ATMega16U2 chip as the USB to UART bridge, that bridge chip can be reprogrammed to appear as a keyboard. For other MCUs there may be software "bit-banged" USB implementations available (such as V-USB), though YMMV with those implementations, and they require building extra hardware to interface the chip to the USB port.

  • Thank you very much for your answer! It's a shame that the NodeMCU cannot be used for this purpose. I see that you have mentioned there are ways of making non-USB boards work as keyboards but I can't see any mention of the NodeMCU specifically; is this because it is impossible to do for this board? If not, would you be able to point me in the right direction of how to do this? Thank you once again!
    – Tom
    Jul 20, 2018 at 12:28
  • yes, it's impossible to make the ch340 or cp2102 into a usb hid like you can the megaxUxs...
    – dandavis
    Jul 20, 2018 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.