Skip to content

Commit 0504d34

Browse files
authored
Merge pull request arduino#658 from arduino/sebromero/keyboard-example
hid: Add example for using keyboard modifiers.
2 parents 089cbe2 + 674e095 commit 0504d34

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
KeyboardModifiers
3+
4+
Select one word each second while extending the current text selection.
5+
6+
The purpose of this demo is to demonstrate how to use the modifier keys.
7+
Some keys such as the arrow and function keys are mapped in a list so you
8+
don't have to know the key codes. You can find them in the file USBKeyboard.h.
9+
10+
For these keys you can use the function key_code().
11+
For other keys such as character keys you need to look up the key codes
12+
and use the key_code_raw() function.
13+
14+
Author: Sebastian Romero @sebromero
15+
16+
This example code is in the public domain.
17+
*/
18+
19+
#include "PluggableUSBHID.h"
20+
#include "USBKeyboard.h"
21+
22+
USBKeyboard Keyboard;
23+
24+
void setup() {}
25+
26+
void loop() {
27+
delay(1000);
28+
Keyboard.key_code(RIGHT_ARROW, KEY_SHIFT | KEY_ALT);
29+
30+
delay(1000);
31+
// Alternatively you can use the raw key code for RIGHT_ARROW 0x4f
32+
Keyboard.key_code_raw(0x4f, KEY_SHIFT | KEY_ALT);
33+
}

0 commit comments

Comments
 (0)