Skip to content

hid: Add example for using keyboard modifiers #658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions libraries/USBHID/examples/KeyboardModifiers/KeyboardModifiers.ino
Original file line number Diff line number Diff line change
@@ -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);
}