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

**URL:** <https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287>\
**Category:** Programming\
**Created:** [October 20, 2020, 2:48pm UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287 "2020-10-20T14:48:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheezewhizz114](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@cheezewhizz114](https://forum.arduino.cc/u/cheezewhizz114)\
**Post date:** [October 20, 2020, 2:48pm UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287/1 "2020-10-20T14:48:37Z")

</div>

```cpp
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Users\CheezWhizz114\Documents\Arduino Project\Receiver __RX_\Receiver__ RX_.ino: In function 'void setup()':

Receiver__RX_:19:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

   Keyboard.begin();

   ^ ~~~~~~~

C:\Users\druid\Documents\Arduino Project\Receiver __RX_\Receiver__ RX_.ino: In function 'void loop()':

Receiver__RX_:35:15: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

               Keyboard.press(KEY_LEFT_GUI);

               ^ ~~~~~~~

Receiver__RX_:35:30: error: 'KEY_LEFT_GUI' was not declared in this scope

               Keyboard.press(KEY_LEFT_GUI);

                              ^ ~~~~~~~~~~~

Receiver__RX_:36:30: error: 'KEY_RIGHT_CTRL' was not declared in this scope

               Keyboard.press(KEY_RIGHT_CTRL);

                              ^ ~~~~~~~~~~~~~

Receiver__RX_:54:30: error: 'KEY_F11' was not declared in this scope

               Keyboard.press(KEY_F11);

                              ^ ~~~~~~

Receiver__RX_:72:15: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

               Keyboard.press(KEY_LEFT_GUI);

               ^ ~~~~~~~

Receiver__RX_:72:30: error: 'KEY_LEFT_GUI' was not declared in this scope

               Keyboard.press(KEY_LEFT_GUI);

                              ^ ~~~~~~~~~~~

Receiver__RX_:100:24: error: 'KEY_LEFT_CTRL' was not declared in this scope

         Keyboard.press(KEY_LEFT_CTRL);

                        ^ ~~~~~~~~~~~~

Receiver__RX_:101:24: error: 'KEY_RIGHT_ARROW' was not declared in this scope

         Keyboard.press(KEY_RIGHT_ARROW);

                        ^ ~~~~~~~~~~~~~~

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.

```

this is the fault I received. I've checked multiple threads beforehand, but I have included the keyboard library outside void setup and void loop, I also have the keyboard library installed, so I don't know what went wrong here. Does someone have an idea? I tried finding custom libraries but after some more searching I thought it wasn't necessary.

The code itsself;

```cpp
#include <Keyboard.h>
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>

RF24 radio(5, 3); // CE, CSN

const byte address[6] = "00001";

int os = 2; //osx = 1, windows = 2, linux = 3
int function = 4; //lock the computer = 1, minimize active window = 2 , show desktop = 3, custom script = 4

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  Keyboard.begin();
}

void loop() {
  if (radio.available()) {
    int trigger;
    radio.read(&trigger, sizeof(trigger));

    if (trigger == 1)
    {
      switch (os)
      {
        case 1: //osx
          switch (function)
          {
            case 1://lock computer
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press(KEY_RIGHT_CTRL);
              Keyboard.press('q');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 2: //minimize active window
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 3: //show desktop
              Keyboard.press(KEY_F11);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 4: //custome script
              while (1);

          }

        case 2: //windows
          switch (function)
          {
            case 1: //lock
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('l');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 2: //minimize active window
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('m');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 3: // show desktop
              Keyboard.press(KEY_LEFT_GUI);
              Keyboard.press('d');
              delay(100);
              Keyboard.releaseAll();
              Serial.println(trigger);
              while (1);

            case 4: //custome script
        Keyboard.press(KEY_LEFT_GUI);
        Keyboard.press(KEY_LEFT_CTRL);
        Keyboard.press(KEY_RIGHT_ARROW);
        delay(50);
        Keyboard.releaseAll();
        Serial.println(trigger);
              while (1);

          }

        case 3: //linux
          switch (function)
          {
            case 1:
              while (1);

            case 2:
              while (1);

            case 3:
              while (1);

            case 4:
              while (1);

          }

        case 4: //custom
        
          while (1);

      }

    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [October 20, 2020, 2:55pm UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287/2 "2020-10-20T14:55:25Z")

</div>

The keyboard library does not work with a Uno

See [Keyboard - Arduino Reference](https://www.arduino.cc/reference/en/language/functions/usb/keyboard/)

---

<div class="post-metadata">

**Author:** ![cheezewhizz114](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@cheezewhizz114](https://forum.arduino.cc/u/cheezewhizz114)\
**Post date:** [October 20, 2020, 2:59pm UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287/3 "2020-10-20T14:59:23Z")

</div>

Thank you, it was a complete fault on my side for not changing the board settings. Though your help just woke me up 😀

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [October 20, 2020, 3:04pm UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287/4 "2020-10-20T15:04:22Z")

</div>

At least you posted the full error output, which many don't, thus allowing it to be seen that you were compiling for a Uno even if that was not the board you were using

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 12:48am UTC](https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287/5 "2021-05-06T00:48:36Z")

</div>

Closed on May 6, 2021, 12:48am UTC


