Is there a more complete USB keyboard library somewhere?

The onboard library to turn the target into a USB keyboard works for keys, but not for LEDs.

There are patches for the standard library for IDE 1.8 to fix that, but that's a bit backward by now...

Any recommendations what library/package one would need to turn a RPi Pico into a keyboard with shift lock/scroll lock/num lock/compose/kata/etc. LEDs?

There is GitHub - NicoHood/HID: Bring enhanced HID functions to your Arduino!; it can e.g. show the caps-lock. It can probably do more but I never fiddled much with it. And I do not know if it will work with your board.

Not sure what you mean by that. Libraries for IDE 1.x work just as well under IDE 2.x.

Hi @treczoks_job. Are you asking for a way to control the LEDs? If so, you can emulate keypresses of the associated keys.

You can use these macros:

  • KEY_CAPS_LOCK
  • KEY_SCROLL_LOCK
  • KEY_NUM_LOCK

Or are you asking for a way to read the state of the LEDs? If so, I think the library recommended by @sterretje will be a good option, but you might also like to know that the addition of such a capability to the Keyboard library has been proposed:

If you have a GitHub account, you can subscribe to those threads to get notifications of any new developments related to this subject:


:red_exclamation_mark: Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.


The Adafruit TinyUSB lib works on the pi pico board. The hid_boot_keyboard example shows processing of the LED status.

1 Like

I had a quick look at the Github Page and the Wiki, and it seems like it does not support the target platform (RPi Pico) - in fact, it explicitely says "no ARM support". So it's not a solution for this.

I've seen that one. It is a patch to the 1.8 core libraries, but I am doubtful it fits the 2.3.6 libraries.

That seems to be a possible solution. I'll investigate and report back.

They are one and the same. The only breaking change to the libraries format was the introduction of the "1.5" format that is supported by Arduino IDE >=1.5.x, but not by <=1.0.x.

However, I didn't take enough care you understand the nature of your question. I just saw "standard library" and jumped to the conclusion we were talking about the official "Keyboard" library. If I had been more careful I would have understood that a different library is used for the Pico board. If you are using the "Raspberry Pi Pico/RP2040/RP2350" boards platform from Earle F. Philhower, III, then it is a variant of that library:

or if you are instead using the "Arduino Mbed OS RP2040 Boards" platform, then it would likely be this one:

So what I wrote is not relevant and the information provided by @customcontroller is the useful assistance.

1 Like

Thank you for your concise answer. It is good to know that the switch from 1.8 to 2.x didn't change much with regards to the libraries, that is important knowledge to stow away for the future.

I am using the " earlephilhower/arduino-pico libraries, and while they do have a function to "install" a callback with OnLED( function, userdata ), there seems to be no actual calling mechanism anywhere in the code for that callback.

I'll check the Adafruit TinyUSB library ASAP.

Just out of curiosity: Is there a reason why this callback for the LED status is implemented neither in the official libraries nor in the Earle Philhower ones?

The callback is implemented in the arduino-pico core. See arduino-pico/libraries/Keyboard/src/Keyboard.cpp at 19b14898eaabcff413b2fae3402922d2a1d4b07c ยท earlephilhower/arduino-pico ยท GitHub and arduino-pico/libraries/Keyboard/examples/KeyboardPassword/KeyboardPassword.ino at master ยท earlephilhower/arduino-pico ยท GitHub . If it doesn't get called, please do open an issue on the GitHub repo w/a sketch showing the problem.

FYI, we use a fork of the standard Arduino library because Keyboard is a HID device and we can use its logic with USB, Bluetooth, and BLE with only minor changes. So we abstract out the transport from the HID packet processing. BT and BLE send the same HID packets as USB devices, just over a different low level transport. Same goes for the Mouse and Joystick...USB==BT==BLE.

2 Likes

Oh, to get an answer from the very source! Thank you for your library, BTW.

So this callback thing is implemented and should work... We'll have a look and check our code accordingly, and will report back.

EDIT: OK, started from scartch based on the KeyboradPassword example, and it works! Thanks again!

A completely different issue, but this made me stumble the whole time. Are you doing the documentation on ReadTheDocs, too? Because the links to the Arduino documentation are broken. On that page, the link to the Arduino docs for SPI go to https://www.arduino.cc/en/reference/SPI, while the actual reference is at https://docs.arduino.cc/language-reference/en/functions/communication/SPI/.

When I wrote those docs 4 years ago, that was the correct link. But Arduino has obviously redone their website since. Feel free to submit a PR on GitHub (you can even do the edits through the website and submit without ever using git on your own system).

1 Like

Possibly better to report it using the contact form: https://www.arduino.cc/en/contact-us.
It's what I usually do.

1 Like

I would suggest doing both. It is good to report it to Arduino so that the website maintainers can set up a redirect from the old URL to the new URL to cause the many links to the old URL that may exist across the Internet to continue to work.

However, even after a redirect is in place, it is still best to update links to point to the new URL instead of relying on the redirect, as there is no guarantee that the redirect will continue to work into the future. What sometimes happens is that the content is moved yet again (the Arduino website is in a state of perpetual churn), and even though a redirect is set up from the old URL to the new URL at that time, for some reason or other the redirect from the old old URL doesn't resolve to the new URL.

1 Like

Even Google's first link into the Arduino docs is busted, too. I'm in good company. :slight_smile: The Arduino CMS redesign must be very new.

When I search for Serial readStringUntil I get the first link from the GOOG page as https://www.arduino.cc/reference/tr/language/functions/communication/serial/readstringuntil which gives

404 Not Found
    Code: NoSuchKey
    Message: The specified key does not exist.
    Key: reference/tr/language/functions/communication/serial/readstringuntil
    RequestId: XZ6VCH78QZHJWAS9
    HostId: wSvEq2iHOqKR5OL6M3PXhiSglX2sRnk3/AG5L6deJXy6NeeI5J08kAA0CBQ13JnAAr1Vsl7pAOg=

I'll put a note in the contact form, but I have no idea if that's actually monitored by anyone who can do anything about it...

1 Like

In my experience issues reported using the form are solved.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.