From 2b841bed483d572e9acd3f7bde9a87d42564d73d Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 24 Oct 2015 10:16:00 +0200 Subject: [PATCH] Updated Keyboard examples --- examples/BootKeyboard/BootKeyboard.ino | 2 +- .../ImprovedKeyboard/ImprovedKeyboard.ino | 48 +++++++++++++++++++ examples/NKROKeyboard/NKROKeyboard.ino | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 examples/ImprovedKeyboard/ImprovedKeyboard.ino diff --git a/examples/BootKeyboard/BootKeyboard.ino b/examples/BootKeyboard/BootKeyboard.ino index 4283132..bf0be40 100644 --- a/examples/BootKeyboard/BootKeyboard.ino +++ b/examples/BootKeyboard/BootKeyboard.ino @@ -8,7 +8,7 @@ Led indicats if we are in bios. See HID Project documentation for more information. - https://github.com/NicoHood/HID/wiki/Keyboard-API + https://github.com/NicoHood/HID/wiki/Keyboard-API#boot-keyboard */ #include "HID-Project.h" diff --git a/examples/ImprovedKeyboard/ImprovedKeyboard.ino b/examples/ImprovedKeyboard/ImprovedKeyboard.ino new file mode 100644 index 0000000..23fb0fa --- /dev/null +++ b/examples/ImprovedKeyboard/ImprovedKeyboard.ino @@ -0,0 +1,48 @@ +/* + Copyright (c) 2014-2015 NicoHood + See the readme for credit to other people. + + Improved Keyboard example + + Shows how to use the new Keyboard API. + + See HID Project documentation for more information. + https://github.com/NicoHood/HID/wiki/Keyboard-API#improved-keyboard +*/ + +#include "HID-Project.h" + +const int pinLed = LED_BUILTIN; +const int pinButton = 2; + +void setup() { + pinMode(pinLed, OUTPUT); + pinMode(pinButton, INPUT_PULLUP); + + // Sends a clean report to the host. This is important on any Arduino type. + Keyboard.begin(); +} + + +void loop() { + // Trigger caps lock manually via button + if (!digitalRead(pinButton)) { + digitalWrite(pinLed, HIGH); + + // Use the default print functions + Keyboard.println("Hello World!"); + + // Press a single character, special non ascii characters wont work. + //Keyboard.write('a'); + + // Write single keys, do not use a number here! + //Keyboard.write(KEY_ENTER); + + // If you really wish to press a RAW keycode without the name use this: + //Keyboard.write(KeyboardKeycode(40)); + + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } +} diff --git a/examples/NKROKeyboard/NKROKeyboard.ino b/examples/NKROKeyboard/NKROKeyboard.ino index 16cd17f..aae4d13 100644 --- a/examples/NKROKeyboard/NKROKeyboard.ino +++ b/examples/NKROKeyboard/NKROKeyboard.ino @@ -11,7 +11,7 @@ You may also use SingleNKROKeyboard to enable a single report NKROKeyboard. See HID Project documentation for more information. - https://github.com/NicoHood/HID/wiki/Keyboard-API + https://github.com/NicoHood/HID/wiki/Keyboard-API#nkro-keyboard */ #include "HID-Project.h"