Fehler bei Keyboard.h

#include "Keyboard.h"

void setup(){
  Keyboard.begin();
}


void loop() {
  Keyboard.press(KEY_LEFT_CTRL);
  delay(500);
  Keyboard.release(KEY_LEFT_CTRL);
  Keyboard.press('e');
  delay(100);
  Keyboard.press('i');
  delay(100);
  Keyboard.press('n');
  delay(100);
  Keyboard.press('g');
  delay(100);
  Keyboard.press('a');
  delay(100);
  Keyboard.press('b');
  delay(100);
  Keyboard.press('e');
  delay(1000);
  Keyboard.press(KEY_RETURN);
  delay(500);
  Keyboard.release(KEY_RETURN);
  delay(1000)
  Keyboard.press('i');
  delay(100);
  Keyboard.press('p');
  delay(100);
  Keyboard.press('c');
  delay(100);
  Keyboard.press('o');
  delay(100);
  Keyboard.press('f');
  delay(100);
  Keyboard.press('i');
  delay(100);
  Keyboard.press('g');
  delay(1000);
  Keyboard.press(KEY_RETURN);
  delay(500);
  Keyboard.release(KEY_RETURN);
  delay(10000)
}

Why i get this Error?
Can someone help please?

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

Hi @prodi. Which board do you have selected from the Arduino IDE's Tools > Board menu?

arduino uno board at com4

The Keyboard library can only be used with Arduino boards that have native USB capabilities. Your Uno does not have native USB capability, so you can't use it with the Keyboard library. This is the cause of the (admittedly confusing) error message.

If you want to use the Keyboard library, I will recommend the Arduino Leonardo, Arduino Micro, or Pro Micro. If you want something a little bit more advanced, the MKR Zero or Nano 33 IoT are good options.

1 Like

Can i use a arduino nano too?

The classic Arduino Nano does not have native USB capabilities and so can not be used with the Keyboard library. The modern Nano 33 IoT does have it because it uses a different microcontroller (ATSAMD21G18 vs. ATmega328P).

The microcontrollers on the Nano 33 BLE, Nano 33 BLE Sense, and Nano RP2040 Connect do have native USB capability, but they aren't currently supported by the Keyboard library. So you can do keyboard emulation with these boards, but you'll need to use a different library. So I only recommend those boards in this particular application for advanced users.

1 Like

ok thank you that helped

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.