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 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:
opened 10:28AM - 29 Jun 22 UTC
type: enhancement
topic: code
### Describe the request
Evaluate the often irrelevant supplemental interpret… ations the Arduino IDE provides on Keyboard and Mouse library-related compilation errors.
- Can false interpretations be reduced?
- Can the interpretation message be adjusted to avoid confusion in the event of false positives?
- Should the interpretations be removed altogether?
### Describe the current behavior
The Arduino IDE attempts to provide some additional guidance to users in response to some specific compilation error messages:
https://github.com/arduino/arduino-ide/blob/34ef25c4e42173d18f64d2f42ff9f24265f16151/arduino-ide-extension/src/node/cli-error-parser.ts#L134-L164
This is accomplished by matching a subset of the error message produced by the compilation toolchain and then printing an additional message in a notification and to the "Output" panel. That message is intended to make the cause and resolution for the error easier for less advanced users to understand.
Two such interpretations were put in place at the time of a breaking change 7 years ago resulting from moving the popular keyboard and mouse emulation APIs out of the core to standalone libraries: https://github.com/arduino/Arduino/pull/3304
Prior to the change, the APIs could be used without adding an extra `#include` directive to the sketch:
```cpp
void setup() {
Keyboard.begin();
Keyboard.print("hello");
}
void loop() {}
```
After the change, it was necessary to add an `#include` directive for the appropriate header file:
```cpp
#include <Keyboard.h>
void setup() {
Keyboard.begin();
Keyboard.print("hello");
}
void loop() {}
```
Attempting to compile the previously valid code results in an error:
```text
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2022528-3144-18az9y0.lofa\sketch_jun28a\sketch_jun28a.ino: In function 'void setup()':
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2022528-3144-18az9y0.lofa\sketch_jun28a\sketch_jun28a.ino:2:3: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~~~~~~~
exit status 1
```
These supplemental interpretations are also displayed by the Arduino IDE:
> 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
> 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Arduino and the Arduino community have done a good job of adapting to the change and it is now very rare to find any legacy code without these `#include` directives. There is always the chance a user will forget to add an `#include` directive in a sketch they write from scratch, but that is just as likely to occur with any arbitrary header file, so does not justify giving these two special treatment.
Meanwhile, another mistake related to keyboard and mouse emulation code is just as prevalent as ever: attempting to use it with a board which does not have native USB support (e.g., [Uno](https://store.arduino.cc/products/arduino-uno-rev3), [Mega](https://store.arduino.cc/products/arduino-mega-2560-rev3)). Unfortunately, doing this produces the same compilation error as omitting the `#include` directive, which also triggers the interpretations. In this case the interpretation message is completely irrelevant because the user already has that `#include` directive in their sketch and the error is caused by something completely different.
🙁 The interpretation message increases confusion in the cases where it is irrelevant. The cases where it is relevant are increasingly rare as time goes on.
- https://forum.arduino.cc/t/what-is-wrong-here/1080550
- https://forum.arduino.cc/t/issue-on-keyboard-library/1065385
- https://forum.arduino.cc/t/sketch-funktioniert-nicht-keyboard/1099364
- https://forum.arduino.cc/t/missing-keyboard-h/1059440
- https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287
- https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/647842
- https://forum.arduino.cc/t/need-help-in-joystick-wasd-keyboard-keys/877912
- https://forum.arduino.cc/t/trying-to-build-alternative-computer-mouse-but-getting-nothing-but-errors/888471
- https://forum.arduino.cc/t/keyboard-h-header-is-not-working/656172
- https://forum.arduino.cc/t/i-have-the-library-on-the-code-but-it-keeps-asking-me-to-add-it/680602
- https://forum.arduino.cc/t/keyboard-h-not-working/934817
- https://forum.arduino.cc/t/old-lady-needs-a-hand-uno-clone/981702
- https://forum.arduino.cc/t/library-included-but-not-found/690756
- https://forum.arduino.cc/t/fehler-bei-keyboard-h/876342
- https://forum.arduino.cc/t/mouse-begin-not-working/676720/9
- https://forum.arduino.cc/t/another-newb-issue/674351
- https://forum.arduino.cc/t/emulation-dun-clavier-pour-une-arduino-mega-keyboard-emulation-for-an-mega/645375
- https://forum.arduino.cc/t/problem-with-nextion/622119
- https://forum.arduino.cc/t/keyboard-key-codes/287528/4
- https://forum.arduino.cc/t/outputting-keys-to-the-computer/427496
- https://forum.arduino.cc/t/makey-makey-source-code-troubles/422137/2
- https://forum.arduino.cc/t/keyboard-not-found-trying-to-clarify/536713
- https://forum.arduino.cc/t/issues-with-uploading-sketch/528862
- https://forum.arduino.cc/t/file-examples-usb-keyboard-keyboardmessage-not-work-this-example/422238/3
- https://forum.arduino.cc/t/trying-to-make-an-arduino-2-keys-keyboard-but-error-pops-up/499126
- https://forum.arduino.cc/t/library-not-found/503525
- https://forum.arduino.cc/t/library-not-working/491054/3
- https://forum.arduino.cc/t/library-error-keyboard-not-found-when-include-keyboard-h-is-included/629788
- https://forum.arduino.cc/t/problems-including-mouse-h/349502
- https://forum.arduino.cc/t/help-with-keyboard-h/551912
- https://forum.arduino.cc/t/arduino-uno-6-1-exscercise/571440
- https://forum.arduino.cc/t/controlling-a-computer-mouse-with-an-arduino-uno-not-working-mouse-h/588081
- https://forum.arduino.cc/t/key-mapping/402444
- https://forum.arduino.cc/t/arduino-nano-keyboard-h-problem/422820
- https://forum.arduino.cc/t/include-library-problem/469783
- https://forum.arduino.cc/t/cant-seem-to-be-able-use-keyboard-h-library/333667/5
- https://forum.arduino.cc/t/error-with-keyboard-library/421403
- https://forum.arduino.cc/t/compiling-example-programs/557209
- https://forum.arduino.cc/t/need-some-help-sending-commands-through-serial-without-a-keyboard/613920/8
- https://forum.arduino.cc/t/keyboard-library-not-working/362325
- https://forum.arduino.cc/t/new-to-this-using-copied-code-getting-errors/488587/27
- https://forum.arduino.cc/t/help-with-mouse-library/574057
- https://forum.arduino.cc/t/keyboard-library-not-working-correctly/583389
- https://forum.arduino.cc/t/arduino-keyboard-library-problem/546147
- https://forum.arduino.cc/t/keyboard-not-found-using-due/545296
- https://forum.arduino.cc/t/unknown-error-for-compiling-my-code-onto-my-arduino-genuino-uno/509186/2
- https://forum.arduino.cc/t/why-is-keyboard-h-library-not-working-on-arduino-uno/472447
- https://forum.arduino.cc/t/keyboard-not-found-on-usb-hid-capable-arduino-uno/450644
- https://forum.arduino.cc/t/keyboard-h-not-supported/427642
- https://forum.arduino.cc/t/compiling-error-doesnt-think-im-including-libraries-that-i-am/378743
- https://forum.arduino.cc/t/arduino-doesnt-seem-to-notice-that-i-have-already-imported-the-library/1008502
- https://forum.arduino.cc/t/keyboard-library-not-being-included/1043892
- https://forum.arduino.cc/t/keyboard-not-found-have-you-included-keyboard-h-in-your-sketch-arduino-uno/1096544
- https://forum.arduino.cc/t/i-have-the-library-installed-but-it-asks-me-to-use-include/1144083
- https://github.com/arduino-libraries/Keyboard/issues/39
- https://github.com/arduino/reference-en/issues/802
### Arduino IDE version
2.0.0-rc8-snapshot-34ef25c
### Operating system
Windows
### Operating system version
10
### Additional context
Related: https://github.com/arduino/arduino-ide/pull/1113
### Issue checklist
- [X] I searched for previous requests in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the feature was still missing when using the latest [nightly build](https://github.com/arduino/arduino-ide#nightly-builds)
- [X] My request contains all necessary details
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.
system
Closed
December 30, 2023, 4:28pm
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.