Arduino HID Keyboard Pfeiltasten und F Tasten

Sorry, hab ich nicht gewusst. Hier der gesamte Code in hoffentlich richtiger Form. Danke

#include "Keyboard.h"

const int buttonPin2 = 2;          // input pin for pushbutton
const int buttonPin3 = 3;
const int buttonPin4 = 4;
const int buttonPin5 = 5;
const int buttonPin6 = 6;
const int buttonPin7 = 7;
const int buttonPin8 = 8;
const int buttonPin9 = 9;
const int buttonPin10 = 10;
int previousButtonState2 = LOW;   // for checking the state of a pushButton
int previousButtonState3 = LOW;
int previousButtonState4 = LOW;
int previousButtonState5 = LOW;
int previousButtonState6 = LOW;
int previousButtonState7 = LOW;
int previousButtonState8 = LOW;
int previousButtonState9 = LOW;
int previousButtonState10 = LOW;

void setup() {
  // make the pushButton pin an input:
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(buttonPin3, INPUT_PULLUP);
  pinMode(buttonPin4, INPUT_PULLUP);
  pinMode(buttonPin5, INPUT_PULLUP);
  pinMode(buttonPin6, INPUT_PULLUP);
  pinMode(buttonPin7, INPUT_PULLUP);
  pinMode(buttonPin8, INPUT_PULLUP);
  pinMode(buttonPin9, INPUT_PULLUP);
  pinMode(buttonPin10, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  // read the pushbutton:
  int buttonState2 = digitalRead(buttonPin2);
  // if the button state has changed,
  while ((buttonState2 != previousButtonState2)
      // and it's currently pressed:
      && (buttonState2 == LOW)){

    // type out a message
Keyboard.press(KEY_LEFT_ARROW);
delay(30);
Keyboard.release(KEY_LEFT_ARROW);
delay(30);
buttonState2 = digitalRead(buttonPin2); 
  }
  // read the pushbutton:
  int buttonState3 = digitalRead(buttonPin3);
  // if the button state has changed,
  if ((buttonState3 != previousButtonState3)
      // and it's currently pressed:
      && (buttonState3 == LOW)) {

    // type out a message
Keyboard.press(KEY_RIGHT_ARROW);
delay(30);
Keyboard.release(KEY_RIGHT_ARROW);
delay(31);
if (buttonState3 = HIGH)
Keyboard.press(KEY_RIGHT_ARROW);
delay(30);
Keyboard.release(KEY_RIGHT_ARROW);
delay(31);

  }
  // read the pushbutton:
  int buttonState4 = digitalRead(buttonPin4);
  // if the button state has changed,
  if ((buttonState4 != previousButtonState4)
      // and it's currently pressed:
      && (buttonState4 == LOW)) {

    // type out a message
 Keyboard.press(KEY_UP_ARROW);
delay(30);
Keyboard.release(KEY_UP_ARROW);
delay(31);
if (buttonState4 = HIGH)
Keyboard.press(KEY_UP_ARROW);
delay(30);
Keyboard.release(KEY_UP_ARROW);
delay(31);

  }
  // read the pushbutton:
  int buttonState5 = digitalRead(buttonPin5);
  // if the button state has changed,
  if ((buttonState5 != previousButtonState5)
      // and it's currently pressed:
      && (buttonState5 == LOW)) {

    // type out a message
Keyboard.press(KEY_DOWN_ARROW);
delay(30);
Keyboard.release(KEY_DOWN_ARROW);
delay(31);
if (buttonState5 = HIGH)
Keyboard.press(KEY_DOWN_ARROW);
delay(30);
Keyboard.release(KEY_DOWN_ARROW);
delay(31);

  }
  // read the pushbutton:
  int buttonState6 = digitalRead(buttonPin6);
  // if the button state has changed,
  if ((buttonState6 != previousButtonState6)
      // and it's currently pressed:
      && (buttonState6 == LOW)) {

    // type out a message
Keyboard.press(KEY_PAGE_UP);
delay(30);
Keyboard.release(KEY_PAGE_UP);
delay(31);
if (buttonState6 = HIGH)
Keyboard.press(KEY_PAGE_UP);
delay(30);
Keyboard.release(KEY_PAGE_UP);
delay(31);

  }
  // read the pushbutton:
  int buttonState7 = digitalRead(buttonPin7);
  // if the button state has changed,
  if ((buttonState7 != previousButtonState7)
      // and it's currently pressed:
      && (buttonState7 == LOW)) {

    // type out a message
Keyboard.press(KEY_PAGE_DOWN);
delay(30);
Keyboard.release(KEY_PAGE_DOWN);
delay(31);
if (buttonState7 = HIGH)
Keyboard.press(KEY_PAGE_DOWN);
delay(30);
Keyboard.release(KEY_PAGE_DOWN);
delay(31);

  }
  // read the pushbutton:
  int buttonState8 = digitalRead(buttonPin8);
  // if the button state has changed,
  if ((buttonState8 != previousButtonState8)
      // and it's currently pressed:
      && (buttonState8 == LOW)) {

    // type out a message
Keyboard.press(KEY_F4);
delay(30);
Keyboard.release(KEY_F4);
  }
  // read the pushbutton:
  int buttonState9 = digitalRead(buttonPin9);
  // if the button state has changed,
  if ((buttonState9 != previousButtonState9)
      // and it's currently pressed:
      && (buttonState9 == LOW)) {

    // type out a message
    Keyboard.print("7");
  }
  // read the pushbutton:
  int buttonState10 = digitalRead(buttonPin10);
  // if the button state has changed,
  if ((buttonState10 != previousButtonState10)
      // and it's currently pressed:
      && (buttonState10 == LOW)) {

    // type out a message
    Keyboard.print("8");
  }
  // save the current button state for comparison next time:
  previousButtonState2 = buttonState2;
  previousButtonState3 = buttonState3;
  previousButtonState4 = buttonState4;
  previousButtonState5 = buttonState5;
  previousButtonState6 = buttonState6;
  previousButtonState7 = buttonState7;
  previousButtonState8 = buttonState8;
  previousButtonState9 = buttonState9;
  previousButtonState10 = buttonState10;
}

/*
KEY_LEFT_CTRL
KEY_LEFT_SHIFT
KEY_LEFT_ALT 
KEY_LEFT_GUI 
KEY_RIGHT_CTRL
KEY_RIGHT_SHIFT
KEY_RIGHT_ALT 
KEY_RIGHT_GUI 
KEY_UP_ARROW 
KEY_DOWN_ARROW
KEY_LEFT_ARROW
KEY_RIGHT_ARROW
KEY_BACKSPACE     
KEY_TAB 
KEY_RETURN
KEY_ESC 
KEY_INSERT
KEY_DELETE
KEY_PAGE_UP
KEY_PAGE_DOWN
KEY_HOME
KEY_END 
KEY_CAPS_LOCK
KEY_F1 
KEY_F2 
KEY_F3 
KEY_F4 
KEY_F5 
KEY_F6 
KEY_F7 
KEY_F8 
KEY_F9 
KEY_F10 
KEY_F11 
KEY_F12
*/