Keyboard.h: No such file or directory - Arduino pro micro (leonardo) I've just bought a new pro-micro and I want to simulate some keyboard inputs with it, the thing is the Arduino IDE (version 2:1.0.5) can't seem to find neither HID.h or Keyboard.h libraries. The steps to reproduce the problem are:


plug the device using usb cable on the pc
Open arduino ide
try to compile my code
it fails with the error 



  test_keyboard.ino:27:22: fatal error: Keyboard.h: No such file or directory
  compilation terminated.


The code is:

#include &lt;Keyboard.h&gt;

void typeKey(int key)
{
  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

/* Init function */
void setup()
{
  // Begining the Keyboard stream
  Keyboard.begin();

  delay(400);

  //Keyboard.press(KEY_LEFT_GUI);

  Keyboard.press(KEY_CTRL);
  Keyboard.press(KEY_ALT);
  Keyboard.press(KEY_T);

  Keyboard.releaseAll();

  delay(100);

  Keyboard.print("echo 'hello world'");

  typeKey(KEY_RETURN);

  delay(100);

  // Ending stream
  Keyboard.end();
}

/* Unused endless loop */
void loop() {}


By the way, I'm running this on linux, after pluging it and running lsusb on terminal I got:
  Bus 002 Device 071: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)
The Keyboard functions were moved into their own library in Arduino IDE 1.6.6/Arduino AVR Boards 1.6.9. In previous Arduino AVR Boards versions, those functions were part of the core library and there was no Keyboard library or Keyboard.h. Since you're using a very outdated version of the Arduino IDE, you don't have a Keyboard library, thus the error. There are two options to solve this problem:


Remove the line #include &lt;Keyboard.h&gt; from your sketch.
Update to a modern version of the Arduino IDE. Note that when you install the Arduino IDE via sudo apt-get install arduino, you end up with the very outdated IDE version you're using. I recommend always installing the official Arduino IDE downloaded from https://www.arduino.cc/en/Main/Software.




For anyone wanting to write code that's backwards compatible with old IDE versions, you can do this:

#if ARDUINO &gt; 10605
#include &lt;Keyboard.h&gt;
#endif




Reference: https://github.com/arduino/Arduino/pull/3304