Reference.KeyboardWrite History

Hide minor edits - Show changes to output

June 26, 2012, at 06:20 PM by David A. Mellis -
Changed lines 7-13 from:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(97) will send 'a'). This is similar to pressing and releasing a key on your keyboard.

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.

to:
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 [[KeyboardModifiers | 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').
May 19, 2012, at 03:43 AM by Tom Igoe -
Changed line 27 from:
Keyoard.write('A'); // same thing as a quoted character
to:
Keyboard.write('A'); // same thing as a quoted character
May 19, 2012, at 03:39 AM by Tom Igoe -
Changed lines 26-29 from:
Keyboard.write(65); // sends ASCII value 65, or A
Keyboard.write('A'); // same thing as a quoted character
Keyboard.write(0x41); // same thing in hexadecimal
Keyboard.write(0b01000001); // same thing in binary (weird choice, but it works)
to:
Keyboard.write(65); // sends ASCII value 65, or A
Keyoard.write('A'); // same thing as a quoted character
Keyboard.write(0x41); // same thing in hexadecimal
Keyboard.write(0b01000001); // same thing in binary (weird choice, but it works)
May 19, 2012, at 03:38 AM by Tom Igoe -
Changed line 26 from:
Keyboard.write(65); // sends ASCII value 65, or A
to:
Keyboard.write(65); // sends ASCII value 65, or A
May 19, 2012, at 03:37 AM by Tom Igoe -
Changed lines 26-29 from:
Keyboard.write(65); // sends ASCII value 65, or A
Keyboard.write('A'); // same thing as a quoted character
Keyboard.write(0x41); // same thing in hexadecimal
Keyboard.write(0b01000001); // same thing in binary (weird choice, but it works)
to:
Keyboard.write(65); // sends ASCII value 65, or A
Keyboard.write('A'); // same thing as a quoted character
Keyboard.write(0x41); // same thing in hexadecimal
Keyboard.write(0b01000001); // same thing in binary (weird choice, but it works)
May 19, 2012, at 03:35 AM by Tom Igoe -
Changed line 26 from:
Keyboard.write(65); // sends ASCII value 65, or A
to:
Keyboard.write(65); // sends ASCII value 65, or A
May 19, 2012, at 03:34 AM by Tom Igoe -
Added line 13:
Changed lines 23-29 from:
character : a char or int to be sent to the computer

!!!!Returns

int : number of bytes sent

!!!!Example
to:
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:
Added lines 26-38:
Keyboard.write(65); // sends ASCII value 65, or A
Keyboard.write('A'); // same thing as a quoted character
Keyboard.write(0x41); // same thing in hexadecimal
Keyboard.write(0b01000001); // same thing in binary (weird choice, but it works)
(:sourceend:)


!!!!Returns

int : number of bytes sent

!!!!Example
(:source lang=arduino tabwidth=4:)
May 18, 2012, at 04:48 PM by Scott Fitzgerald - expanded how write() works
Changed lines 7-8 from:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send 'A'). This is similar to pressing and releasing a key on your keyboard.
to:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(97) will send 'a'). This is similar to pressing and releasing a key on your keyboard.

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.

For a complete list of ASCII characters, see [[http://www.asciitable.com/ | ASCIITable.com]].
April 28, 2012, at 12:37 AM by Scott Fitzgerald -
Changed lines 23-40 from:
to:
(:source lang=arduino tabwidth=4:)
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);
Keyboard.begin();
}

void loop() {
//if the button is pressed
if(digitalRead(2)==LOW){
//Send an ASCII 'A',
Keyboard.write(65);
}
}
(:sourceend:)
Changed line 49 from:
*[[/Tutorial/ASCIITable | ASCIITable]] tutorial
to:
*[[/Tutorial/ASCIITable | ASCIITable]] tutorial
April 27, 2012, at 10:46 PM by Scott Fitzgerald -
Added line 32:
*[[/Tutorial/ASCIITable | ASCIITable]] tutorial
April 27, 2012, at 10:45 PM by Scott Fitzgerald -
Changed lines 20-21 from:
int : number of bytes sent\\
\\
to:
int : number of bytes sent

!!!!Example

!!!!See Also
*[[/Reference/KeyboardBegin | Keyboard.begin]]()
*[[/Reference/KeyboardEnd | Keyboard.end]]()
*[[/Reference/KeyboardPress | Keyboard.press]]()
*[[/Reference/KeyboardPrint | Keyboard.print]]()
*[[/Reference/KeyboardPrintln | Keyboard.println]]()
*[[/Reference/KeyboardRelease | Keyboard.release]]()
*[[/Reference/KeyboardReleaseAll | Keyboard.releaseAll]]()
April 16, 2012, at 04:55 PM by Scott Fitzgerald -
Changed lines 7-8 from:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send 'A').
to:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send 'A'). This is similar to pressing and releasing a key on your keyboard.
Changed line 21 from:
\\
to:
\\
November 30, 2011, at 05:53 AM by Scott Fitzgerald -
Changed lines 7-8 from:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send an "A").
to:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send 'A').
November 30, 2011, at 05:53 AM by Scott Fitzgerald -
Changed line 20 from:
int : number of bytes sent
to:
int : number of bytes sent\\
November 30, 2011, at 05:52 AM by Scott Fitzgerald -
Changed lines 7-8 from:
Sends a keystroke to a connected computer.
to:
Sends a keystroke to a connected computer. If sending a numeric type, it sends it as an ASCII character (ex. Keyboard.write(65) will send an "A").
Changed line 21 from:
\\
to:
\\
November 30, 2011, at 04:56 AM by Scott Fitzgerald -
Added line 21:
\\
November 30, 2011, at 04:53 AM by Scott Fitzgerald -
Added lines 1-20:
[[Reference/MouseKeyboard | Keyboard]]

!!Keyboard.write()

!!!!Description

Sends a keystroke to a connected computer.

WARNING: 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.

!!!!Syntax
Keyboard.write(character)

!!!!Parameters

character : a char or int to be sent to the computer

!!!!Returns

int : number of bytes sent

Share