I have the library installed but it asks me to use #include

heres my code

#include <Keyboard.h>


void setup() {
  // make pin 2 an input and turn on the
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  while (digitalRead(2) == HIGH) {
    // do nothing until pin 2 goes low
    delay(500);
  }
  delay(1000);
  // new document:
  Keyboard.press(KEY_LEFT_CTRL);
  Keyboard.press('c');
  delay(100);
  Keyboard.releaseAll();
  // wait for new window to open:
  delay(1000);
}

"installed" means that it is on your PC.
"#include" means that it is used in your code.

i know i used #include and its a preinstalled library

Welcome to the forum

Which Arduino board are you using ?

uno elegoo branded but they are exactly the same

The Keyboard library is not compatible with the Uno

See Keyboard - Arduino Reference

Your problem is more a "programming question" than specific to IDE 1.x; you would encounter the same problem in IDE 2.x :wink: Hence your topic has been moved to a more suitable location on the forum.

UKHeliBob already gave the essential explanation.


I'll add a link to some superfluous related information in case anyone is interested in the boring details of why you get this strange message when attempting to compile the sketch for an Uno, it is explained (and a change to that behavior proposed) here:

Note that if are encountering this error and only want to get on with your project then all you need to know is that the Keyboard library can only be used with the specific boards it is compatible with. The information at the link above is only for those who are curious to know the low level "why" behind the IDE's odd behavior.

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