A modifier key is a key on a computer’s keyboard that is only used in conjunction with another key. Modifier keys are often used with other keys to perform computer keyboard shortcuts and other commands. For example, in many text editor programs pressing the Ctrl+A will select all text.
Below is the list of Keyboard Modifiers that can be used with the Keyboard.press() function in the Arduino keyboard library.
Command | Key in Windows | Key in OSX |
KEY_LEFT_CTRL | Left CTRL | |
KEY_LEFT_SHIFT | Left SHIFT | Left SHIFT |
KEY_LEFT_ALT | Left ALT | Left OPTION |
KEY_LEFT_GUI | Left WIN KEY | Left COMMAND |
KEY_RIGHT_CTRL | Right CTRL | |
KEY_RIGHT_SHIFT | Right SHIFT | Right SHIFT |
KEY_RIGHT_ALT | Right ALT | OPTION |
KEY_RIGHT_GUI | Right WIN KEY | Right COMMAND |
KEY_UP_ARROW | UP ARROW | UP ARROW |
KEY_DOWN_ARROW | DOWN ARROW | DOWN ARROW |
KEY_LEFT_ARROW | LEFT ARROW | LEFT ARROW |
KEY_RIGHT_ARROW | RIGHT ARROW | RIGHT ARROW |
KEY_BACKSPACE | BACKSPACE | DELETE |
KEY_TAB | TAB | TAB |
KEY_RETURN | ENTER | RETURN |
KEY_ESC | ESC | ESC |
KEY_INSERT | INSERT | |
KEY_DELETE | DELETE | |
KEY_PAGE_UP | PAGE_UP | |
KEY_PAGE_DOWN | PAGE_DOWN | |
KEY_HOME | HOME | |
KEY_END | END | |
KEY_CAPS_LOCK | CAPSLOCK | CAPSLOCK |
KEY_F1 | F1 | F1 |
KEY_F2 | F2 | F2 |
KEY_F3 | F3 | F3 |
KEY_F4 | F4 | F4 |
KEY_F5 | F5 | F5 |
KEY_F6 | F6 | F6 |
KEY_F7 | F7 | F7 |
KEY_F8 | F8 | F8 |
KEY_F9 | F9 | F9 |
KEY_F10 | F10 | F10 |
KEY_F11 | F11 | F11 |
KEY_F12 | F12 | F12 |
KEY_F13 | SHIFT + F1 | FN + F1 |
KEY_F14 | SHIFT + F2 | FN + F2 |
KEY_F15 | SHIFT + F3 | FN + F3 |
KEY_F16 | SHIFT + F4 | FN + F4 |
KEY_F17 | SHIFT + F5 | FN + F5 |
KEY_F18 | SHIFT + F6 | FN + F6 |
KEY_F19 | SHIFT + F7 | FN + F7 |
KEY_F20 | SHIFT + F8 | FN + F8 |
KEY_F21 | SHIFT + F9 | FN + F9 |
KEY_F22 | SHIFT + F10 | FN + F10 |
KEY_F23 | SHIFT + F11 | FN + F11 |
KEY_F24 | SHIFT + F12 | FN + F12 |
Example Codes
Program to open a new window. Taken from arduino.cc
#include// use this option for OSX: char ctrlKey = KEY_LEFT_GUI; // use this option for Windows and Linux: // char ctrlKey = KEY_LEFT_CTRL; 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(ctrlKey); Keyboard.press('n'); delay(100); Keyboard.releaseAll(); // wait for new window to open: delay(1000); }