Diode and problem with the code

When programming ir diodes, an error pops up - arduino uno

Tile: "Arduino / Genuino Uno"
W funkcji 'void setup ()':
error: Nie znaleziono klawiatury. Czy twój szkic zawiera linię "#include <Keyboard.h>"?
Keyboard.begin ();
W funkcji 'void loop ()':

Pilot-MediaPlayer-Youtube: 51: 7: error: Nie znaleziono klawiatury. Czy twój szkic zawiera linię "#include <Keyboard.h>"?
Keyboard.press (KEY_LEFT_CTRL);

^

Pilot-MediaPlayer-Youtube: 51: 22: błąd: "KEY_LEFT_CTRL" nie został zadeklarowany w tym zakresie

Keyboard.press (KEY_LEFT_CTRL);

^

Pilot-MediaPlayer-Youtube: 59: 7: error: Nie znaleziono klawiatury. Czy twój szkic zawiera linię?
Keyboard.press (KEY_LEFT_CTRL);

^

Pilot-MediaPlayer-Youtube: 59: 22: błąd: "KEY_LEFT_CTRL" nie został zadeklarowany w tym zakresie

Keyboard.press (KEY_LEFT_CTRL);

^

Pilot-MediaPlayer-Youtube: 67: 7: error: Nie znaleziono klawiatury. Czy twój szkic zawiera linię "#include <Keyboard.h>"?
Keyboard.press (KEY_LEFT_CTRL);

^

Pilot-MediaPlayer-Youtube: 67: 22: błąd: "KEY_LEFT_CTRL" nie został zadeklarowany w tym zakresie
Thank you in advance for your response

Code:

#include "Keyboard.h"
#include <IRremote.h>

int RECV_PIN = 10;

volatile boolean mode = 0;
//0 - Media Player
//1 - YouTube

IRrecv irrecv(RECV_PIN);

decode_results results;

#define PP 0xFFC23D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define VPLUS 0xFFA857
#define VDOWN 0xFFE01F

#define VIEW1 0xFF30CF
#define VIEW2 0xFF18E7
#define VIEW3 0xFF7A85

#define MODE 0xFF629D
#define FULLSCREEN 0xFF6897

void setup() {

Keyboard.begin();
irrecv.enableIRIn();
pinMode(8, 1);
}

void loop() {

if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);

if( results.value == MODE ) toggleMode();
if( mode == 0 ) digitalWrite(8, LOW);
if( mode == 1 ) digitalWrite(8, HIGH);
irrecv.resume();

if( mode == 0 ){
if( results.value == PP ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('p');
delay(50);
Keyboard.releaseAll();
}

else if( results.value == PREV ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('b');
delay(50);
Keyboard.releaseAll();
}

else if( results.value == NEXT ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('f');
delay(50);
Keyboard.releaseAll();
}

else if( results.value == VPLUS ) {

Keyboard.press(KEY_F9);
delay(200);
Keyboard.releaseAll();
}

else if( results.value == VDOWN ) {

Keyboard.press(KEY_F8);
delay(200);
Keyboard.releaseAll();
}

else if( results.value == VIEW1 ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('1');
delay(500);
Keyboard.releaseAll();
}

else if( results.value == VIEW2 ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('2');
delay(500);
Keyboard.releaseAll();
}

else if( results.value == VIEW3 ) {

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('3');
delay(500);
Keyboard.releaseAll();
}
}

else if( mode == 1 ){

if( results.value == PP ) {

Keyboard.press('k');
delay(50);
Keyboard.releaseAll();
}

if( results.value == PREV ) {

Keyboard.press('j');
delay(50);
Keyboard.releaseAll();
}

if( results.value == NEXT ) {

Keyboard.press('l');
delay(50);
Keyboard.releaseAll();
}

if( results.value == VPLUS ) {

Keyboard.press(KEY_UP_ARROW);
delay(5);
Keyboard.releaseAll();
}

if( results.value == VDOWN ) {

Keyboard.press(KEY_DOWN_ARROW);
delay(5);
Keyboard.releaseAll();
}

if( results.value == FULLSCREEN ) {

Keyboard.press('f');
delay(50);
Keyboard.releaseAll();
}

}
irrecv.resume();
}
}

boolean toggleMode(){

if( mode == 0 ) mode = 1;
else if( mode == 1) mode = 0;
delay(500);
}

Must we guess what the error is? When you get an error, click the 'copy error messages' button in the IDE and post the message here.

Please read How to use this forum - please read., specifically point 7. Please apply what you read there to both the code (modify your previous post) and to the error messages that you're going to post (in a new reply).

Which Arduino are you using?

Which Areduino board are you using ?
Does it support the use of the Keyboard library ?

seboke:
When programming ir diodes, an error pops up
Thank you in advance for your response

When I select the Arduino Leonardo, I get no error.

johnwasser:
When I select the Arduino Leonardo, I get no error.

Me neither, hence my question

I can't read your error messages, but:

...
Tile: "Arduino / Genuino Uno"
...

As mentioned above, the Uno does not support the keyboard library - it doesn't have the hardware built in. Only boards based on the 32u4 instead of the 328p work with keyboard.h. Official Arduino boards Leonardo and Micro use that chip, as do a number of third party boards such as Sparkfun Pro Micro, PJRC Teensy 2.0 and DFRobot Beetle among others.

ChrisTenone:
I can't read your error messages, but:

As mentioned above, the Uno does not support the keyboard library - it doesn't have the hardware built in. Only boards based on the 32u4 instead of the 328p work with keyboard.h. Official Arduino boards Leonardo and Micro use that chip, as do a number of third party boards such as Sparkfun Pro Micro, PJRC Teensy 2.0 and DFRobot Beetle among others.

from what I know it can be done to be read like a keyboard because I have done so

Not with an UNO, you haven't.

I love these Polish error messages they really make clear what is going on.

MorganS:
Not with an UNO, you haven't.

how to connect arduino it works as a keyboard

Did that solve your problem?

seboke:
GitHub - NicoHood/Hoodloader: Advanced HID Firmware for Arduino Uno/Mega
how to connect arduino it works as a keyboard

Yes, you can replace the USB-to-Serial firmware on the 16u2 processor (used for USB to Serial conversion on the genuine Arduino UNO, Arduino MEGA ,and a few clones) but that doesn't work with the "Keyboard" library. You have to send special serial sequences from the ATmega328P to the 16u2 to get it to act like a USB keyboard.

johnwasser:
Yes, you can replace the USB-to-Serial firmware on the 16u2 processor (used for USB to Serial conversion on the genuine Arduino UNO, Arduino MEGA ,and a few clones) but that doesn't work with the "Keyboard" library. You have to send special serial sequences from the ATmega328P to the 16u2 to get it to act like a USB keyboard.

So what should I write?

seboke:
So what should I write?

Keep your existing code and buy an Arduino Leonardo or Arduino Micro.

Processors that can emulate keyboards, mouses and other usb devices, all have a ‘u’ in their name. It means usb I guess.