Arduino

Reference Language | Libraries | Comparison | Changes

Keyboard

## Keyboard.println()

#### Description

Sends a keystroke to a connected computer, followed by a newline and carriage return.

Keyboard.println() must be called after initiating Keyboard.begin().

WARNING: When you use the Keyboard.println() 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.println()
Keyboard.println(character)
Keyboard.println(characters)

#### Parameters

character : a char or int to be sent to the computer as a keystroke, followed by newline and carriage return.
characters : a string to be sent to the computer as a keystroke, followed by a newline and carriage return.

#### Returns

int : number of bytes sent

#### Example

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 the message
Keyboard.println("Hello!");
}
}
[Get Code]

#### See Also

- Keyboard.begin()
- Keyboard.end()
- Keyboard.press()
- Keyboard.print()
- Keyboard.release()
- Keyboard.releaseAll()
- Keyboard.write()

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- Careers