Help with keyboard.press example not working

I am new and would like some help with project I would like to do.

I have wired up simple one button on my Arduino Uno:
Arduino IDE = 1.8.1

Here is link to board I have

All I would like to do is use Keyboard.press with few buttons (shortcut keys).

#include <keyboard.h> // Have tried running without this command as well as replacing <> with “”

// use this option for OSX:
// char ctrlKey = KEY_LEFT_GUI;
// use this option for Windows and Linux:
char ctrlKey = KEY_LEFT_CTRL;

void setup() {
// make pin 2 an input and turn on the
// pullup resistor so it goes high unless
// connected to ground:
pinMode(2, INPUT_PULLUP);
// initialize control over the keyboard:
Keyboard.begin();
}

void loop() {
while (digitalRead(2) == HIGH) {
// do nothing until pin 2 goes low
delay(500);
}
delay(1000);
// new document:
Keyboard.press(ctrlKey);
Keyboard.press(‘n’);
delay(100);
Keyboard.releaseAll();
// wait for new window to open:
delay(1000);
}

Here is the Error I recieve:
\sketch_feb24b.ino:1:22: fatal error: keyboard.h: No such file or directory

#include <keyboard.h>

^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

According to the website this board has the Atmega16u2 chip allowing it to show up as keyboard.

Any help would be greatly appreciated.

The Uno doesn’t support use of the Keyboard library. You need an ATmega32U4 based board (such as Pro Micro or Leonardo) or Due or Zero. Also, the correct filename is Keyboard.h. Filename case does matter on some operating systems.

pert:
The Uno doesn’t support use of the Keyboard library. You need an ATmega32U4 based board (such as Pro Micro or Leonardo) or Due or Zero. Also, the correct filename is Keyboard.h. Filename case does matter on some operating systems.

That was it, my problem was simple just as I suspected!!!. I had mispelled the #include <Keyboard.h>

I have read that can upgrade firmware to make UNO run as a Leonardo. I myself had problems getting Flip to load .hex file so Giving up there I think my best bet is just order leonardo board.

Would updating Arduino Mega work (have one of those as well) as Leonard?

Thank you for your help!!

Mega has the same issue as Uno in that the main microcontroller (ATmega2560) doesn't support the USB capabilities you need. Real Arduino boards and some clones use the ATmega16U2 microcontroller for the USB-serial chip, which does support this. So the situation will be the same with the Mega assuming your Uno and Mega both use the same USB-serial chip. I haven't done this before but you are correct it can be done. I think it's a bit advanced. This is the project I know of for doing it:

pert:
Mega has the same issue as Uno in that the main microcontroller (ATmega2560) doesn't support the USB capabilities you need. Real Arduino boards and some clones use the ATmega16U2 microcontroller for the USB-serial chip, which does support this. So the situation will be the same with the Mega assuming your Uno and Mega both use the same USB-serial chip. I haven't done this before but you are correct it can be done. I think it's a bit advanced. This is the project I know of for doing it:
GitHub - NicoHood/HID: Bring enhanced HID functions to your Arduino!

Thank you Pert. Really appreciate the help. Will check out that link.

Just ordered leonardo board and will wait on it for now. Just work on my code for multiple buttons..

I agree that using a Leonardo is the easiest and probably the best option. I’m experienced enough to make my Uno do this but I haven’t ever bothered because I can just use my Pro Micro for the task instead.