Source: https://mokxi.com/errors/usbhidkeyboard-h-no-such-file-or-directory
Updated: 2026-11-16

Home / Errors
Arduino build error

# fatal error: USBHIDKeyboard.h: No such file or directory

USBHIDKeyboard.h is the keyboard library of the ESP32-S2 and ESP32-S3, which can be a USB device.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes

The message

## What the Arduino IDE prints

Output window

An Uno cannot be a USB keyboard at all. A Leonardo, Micro or Pro Micro can, with Keyboard.h.

Mokxi's compiler, clang, words it as 'USBHIDKeyboard.h' file not found.

Causes

## The 2 usual causes with the fix

### 1The board cannot be a USB keyboard

Choose a board that talks USB itself. The Leonardo, Micro and Pro Micro use #include <Keyboard.h>.

Broken

Fixed

Mokxi’s build tab says: This project has no file named USBHIDKeyboard.h.

Try this fix in Mokxi

### 2An ESP32 board without USB device mode

An ESP32-S3 needs its USB mode set before USBHIDKeyboard.h is available.

- Choose an ESP32-S2 or ESP32-S3 board, not a classic ESP32. The classic ESP32 has no USB device port.
- In Tools, set USB Mode to USB-OTG (TinyUSB), and compile again.
- Add #include "USB.h" and call USB.begin() after keyboard.begin().

FAQ

## Questions and answers

### Which boards can be a USB keyboard?

Boards with a chip that has USB built in: the Leonardo, Micro, Pro Micro, ESP32-S2, ESP32-S3 and the Raspberry Pi Pico.

### Why not the Uno?

The Uno has a separate chip for USB, so the main chip cannot act as a keyboard.

### Does Keyboard work in Mokxi?

Yes. Mokxi runs Keyboard.h sketches on a Leonardo, Micro or Pro Micro.

Next

## More errors and the longer guide

- fatal error: WiFi.h: No such file or directory
- fatal error: Servo.h: No such file or directory

The longer guide to this error All Arduino errors
