From 674e095285249adbfff0baa449b73db57dce7a08 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Fri, 7 Apr 2023 15:55:32 +0200 Subject: [PATCH] hid: Add example for using keyboard modifiers --- .../KeyboardModifiers/KeyboardModifiers.ino | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libraries/USBHID/examples/KeyboardModifiers/KeyboardModifiers.ino diff --git a/libraries/USBHID/examples/KeyboardModifiers/KeyboardModifiers.ino b/libraries/USBHID/examples/KeyboardModifiers/KeyboardModifiers.ino new file mode 100644 index 000000000..a850cc1e1 --- /dev/null +++ b/libraries/USBHID/examples/KeyboardModifiers/KeyboardModifiers.ino @@ -0,0 +1,33 @@ +/* + KeyboardModifiers + + Select one word each second while extending the current text selection. + + The purpose of this demo is to demonstrate how to use the modifier keys. + Some keys such as the arrow and function keys are mapped in a list so you + don't have to know the key codes. You can find them in the file USBKeyboard.h. + + For these keys you can use the function key_code(). + For other keys such as character keys you need to look up the key codes + and use the key_code_raw() function. + + Author: Sebastian Romero @sebromero + + This example code is in the public domain. +*/ + +#include "PluggableUSBHID.h" +#include "USBKeyboard.h" + +USBKeyboard Keyboard; + +void setup() {} + +void loop() { + delay(1000); + Keyboard.key_code(RIGHT_ARROW, KEY_SHIFT | KEY_ALT); + + delay(1000); + // Alternatively you can use the raw key code for RIGHT_ARROW 0x4f + Keyboard.key_code_raw(0x4f, KEY_SHIFT | KEY_ALT); +}