Arduino sketch – keyboard keys pressed with gpi

#include KEYBOARD.h

const int F9_PIN = 2;
const int F10_PIN = 3;
const int F9_LED_PIN = 4;
const int F10_LED_PIN = 5;

void setup() {
Keyboard.begin();
pinMode(F9_PIN, INPUT_PULLUP);
pinMode(F10_PIN, INPUT_PULLUP);
pinMode(F9_LED_PIN, OUTPUT);
pinMode(F10_LED_PIN, OUTPUT);
}

void loop() {
if (digitalRead(F9_PIN) == LOW) {
Keyboard.press(KEY_F9);
digitalWrite(F9_LED_PIN, HIGH);
delay(100);
Keyboard.release(KEY_F9);
digitalWrite(F9_LED_PIN, LOW);
}

if (digitalRead(F10_PIN) == LOW) {
Keyboard.press(KEY_F10);
digitalWrite(F10_LED_PIN, HIGH);
delay(100);
Keyboard.release(KEY_F10);
digitalWrite(F10_LED_PIN, LOW);
}
}