Skip to content

Multiple fixes in Keyboard.{print,println} #853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 21, 2021
Merged

Multiple fixes in Keyboard.{print,println} #853

merged 3 commits into from
Nov 21, 2021

Conversation

edgar-bonet
Copy link
Contributor

This pull request addresses multiple small issues in keyboardPrint.adoc and keyboardPrintln.adoc:

  1. The syntax of Keyboard.println() is described as:

    Keyboard.println()
    Keyboard.println(character)+ Keyboard.println(characters)

    where the + operator was meant to be a hard line break.

  2. The functions are described as “Sends a keystroke to a connected computer [...]” even though a string is actually sent as a series of keystrokes rather than a single one.

  3. The functions are said to return the “Number of bytes sent”, although they return the number of keystrokes (two 8-byte reports are actually sent for each single keystroke).

  4. Keyboard.println() is said to end the output by “a newline and carriage return”, whereas in reality it sends a press and a release of Return, more commonly known as Enter.

Regarding the last point, the current description of println() seems to imply that it sends the ASCII LF and CR characters, in that unconventional order. It should be noted that:

  • the Keyboard library sends keystrokes, not characters
  • there is no such thing as the “newline” or “carriage return” keys
  • println() terminates the output by a single keystroke

Technically, it would be more correct to specify that it hits the Return key. However, most people use “Return” and “Enter” interchangeably, and “Enter” seems more common and less confusing.

- a string is sent as multiple keystrokes, not as a single keystroke
- these functions return the number of keystrokes sent, which is far
  smaller than the number of bytes.
There is no such thing as the "newline" or "carriage return" keys.
Instead, Keyboard.println() hits the Return key, more commonly known as
the Enter key.
@CLAassistant
Copy link

CLAassistant commented Nov 5, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @edgar-bonet!

@per1234 per1234 merged commit bdd979a into arduino:master Nov 21, 2021
@per1234 per1234 added the bug label Nov 21, 2021
@edgar-bonet edgar-bonet deleted the kbd-println branch November 21, 2021 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants