Keyboard.write()
Description
Sends a keystroke to a connected computer. This is similar to pressing and releasing a key on your keyboard. You can send some ASCII characters or the additional keyboard modifiers and special keys.
Only ASCII characters that are on the keyboard are supported. For example, ASCII 8 (backspace) would work, but ASCII 25 (Substitution) would not. When sending capital letters, Keyboard.write() sends a shift command plus the desired character, just as if typing on a keyboard. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(97) will send 'a').
For a complete list of ASCII characters, see ASCIITable.com.
Syntax
Keyboard.write(character)
Parameter Values
- character: a char or int to be sent to the computer. Can be sent in any notation that's acceptable for a char. For example, all of the below are acceptable and send the same value, 65 or ASCII A:
Return Values
- Number of bytes sent. Data type: size_t.
Example Code
※ NOTES AND WARNINGS:
When you use the Keyboard.write() command, the Arduino takes over your keyboard! Make sure you have control before you use the command. A pushbutton to toggle the keyboard control state is effective.
See Also
- Language : Arduino - Keyboard
- Language : Keyboard.begin()
- Language : Keyboard.end()
- Language : Keyboard Modifiers
- Language : Keyboard.press()
- Language : Keyboard.print()
- Language : Keyboard.println()
- Language : Keyboard.release()
- Language : Keyboard.releaseAll()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Additionally, some links direct to products from our own brand, DIYables.