When given a printable ASCII character as an argument, the functions Keyboard.write()Keyboard.press() and Keyboard.release() simulate actuations on the corresponding keys. These functions can also handle ASCII characters that require pressing a key in combination with Shift or, on international keyboards, AltGr. For example:

Keyboard.write('a');  // press and release the 'A' key
Keyboard.write('A');  // press Shift and 'A', then release both

A typical keyboard, however, has many keys that do not match a printable ASCII character. In order to simulate those keys, the library provides a set of macros that can be passed as arguments to Keyboard.write()Keyboard.press() and Keyboard.release(). For example, the key combination Shift+F2 can be generated by:

Keyboard.press(KEY_LEFT_SHIFT);  // press and hold Shift
Keyboard.press(KEY_F2);          // press and hold F2
Keyboard.releaseAll();           // release both

Note that, in order to press multiple keys simultaneously, one has to use Keyboard.press() rather than Keyboard.write(), as the latter just “hits” the keys (it presses and immediately releases them).

Read More