outputting keys to the computer

Hello,

I am still fairly new to programming and was working on a project where I want to make a shift stick, for games.

So what i did was wrote a piece of code to emulate keys to the computer like i saw on the arduino playground: Keyboard.write() - Arduino Reference
but it doesn't work. So I made a few chages but it still doesn't work, this is the code:

#include <Keyboard.h>

int gear0 = 1;
int gear1 = 2;
int gear2 = 3;
int gear3 = 4;
int gear4 = 5;
int gear5 = 6;
int gear6 = 7;
void setup() {
// put your setup code here, to run once:
pinMode(gear0, INPUT);
pinMode(gear1, INPUT);
pinMode(gear2, INPUT);
pinMode(gear3, INPUT);
pinMode(gear4, INPUT);
pinMode(gear5, INPUT);
pinMode(gear6, INPUT);

Keyboard.begin();
}

void loop() {
if(digitalRead(gear0) == HIGH){
Keyboard.press(0);
delay(500);
}
if(digitalRead(gear1) == HIGH){
Keyboard.press(1);
delay(500);
}
if(digitalRead(gear2) == HIGH){
Keyboard.press(2);
delay(500);
}
if(digitalRead(gear3) == HIGH){
Keyboard.press(3);
delay(500);
}
if(digitalRead(gear4) == HIGH){
Keyboard.press(4);
delay(500);
}
if(digitalRead(gear5) == HIGH){
Keyboard.press(5);
delay(500);
}
if(digitalRead(gear6) == HIGH){
Keyboard.press(6);
delay(500);
}
}

the error i get is

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

If i posted in the wrong section please tell me.

kind regards, Vincent

Please post the complete error message, AND USE CODE TAGS WHEN POSTING CODE.

Keyboard is only supported by Leonardo, Micro and maybe Due.

Do you run your sketch on such a device?

AWOL:
Please post the complete error message, AND USE CODE TAGS WHEN POSTING CODE.

Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\vincent\Documents\Arduino\sketch_nov06a\gearboxv2\gearboxv2.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]

#warning "Using legacy HID core (non pluggable)"

^

C:\Users\vincent\Documents\Arduino\sketch_nov06a\gearboxv2\gearboxv2.ino: In function 'void setup()':

gearboxv2:20: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();

^

C:\Users\vincent\Documents\Arduino\sketch_nov06a\gearboxv2\gearboxv2.ino: In function 'void loop()':

gearboxv2:25: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(0);

^

gearboxv2:29: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(1);

^

gearboxv2:33: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(2);

^

gearboxv2:37: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(3);

^

gearboxv2:41: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(4);

^

gearboxv2:45: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(5);

^

gearboxv2:49: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(6);

^

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.

Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"

And there's your answer.
If only you'd posted that originally and saved all our time.

Whandall:
Keyboard is only supported by Leonardo, Micro and maybe Due.

Do you run your sketch on such a device?

I am only compiling it not running it

AWOL:

Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"

And there's your answer.
If only you'd posted that originally and saved all our time.

ok thanks

vinceverc:
I am only compiling it not running it

So why don't you compile it for a platform that supports it?

Note: Keyboard.press(5); will not get you the key for the digit 5. For that you want Keyboard.press('5');