Keyboard.h not working

#include <Mouse.h>

#include <Keyboard.h>

const int One = 13;
const int Two = 6;
const int Three = 10;
const int Four = 11;
const int CensorBtn = 0;
const int PhoneBtn = 1;
const int BrodcastScreenVol = 0;
const int MasterScreenVol = 1;
const int InterferenceSlide = 2;
const int Yaxis = 3;
const int Xaxis = 4;
const int A = 2;
const int B = 3;
const int C = 4;

void setup() {
pinMode(One, INPUT_PULLUP);
pinMode(Two, INPUT_PULLUP);
pinMode(Three, INPUT_PULLUP);
pinMode(Four, INPUT_PULLUP);
pinMode(CensorBtn, INPUT_PULLUP);
pinMode(PhoneBtn, INPUT_PULLUP);


void loop() {
// put your main code here, to run repeatedly:


Arduino: 1.8.16 (Windows Store (Windows 10), Board: "Arduino Uno"

In function 'void setup()':

sketch_dec11a:30:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?



exit status 1

'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

That misleading error message is caused by trying to use the Keyboard library with a board it is not compatible with.

You cannot use the Arduino Uno with the Keyboard library because the Uno does not have the necessary USB capabilities. You must use an Arduino board with native USB capabilities such as the Arduino Leonardo, Pro Micro, Arduino Micro, MKR Boards, or Nano 33 IoT.

If you have one of those boards, then make sure to select the correct board from the Arduino IDE's Tools > Board menu. If you do have an Uno then you simply can't use the Keyboard library.

1 Like

Thank you so much this really helped

You are welcome. I'm glad if I was able to be of assistance.

1 Like

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