Skip to main content
oeliks
Associate III
December 30, 2019
Solved

Read state of caps lock from keyboard

  • December 30, 2019
  • 2 replies
  • 2094 views

keyboard-pc-usb-stm32

Is it possible to read state of capslock on/off with stm?

Using HAL and cubemx HID configuration.

I can send report. But how to receive report - status?​

This topic has been closed for replies.
Best answer by waclawek.jan

> Is it possible to read state of capslock on/off with stm

No, but this is regardless of whether "with stm" or without. The USB keyboard is completely state-less - it reports which keys are currently pressed, and CAPS LOCK is not different from any other ordinary key. It's the host which has to maintain the CAPS-toggle state, if it implements that at all.

Similarly for LEDs - there is no way to read out the state of LEDs from the keyboard (it even may not implement the LEDs at all). This is even explicitly stated in the standard (HID1.11) in Appendix C:

Synchronization between LED states and CAPS LOCK , NUM L OCK , SCROLL L OCK ,

COMPOSE , and KANA events is maintained by the host and NOT the keyboard

Read the respective USB HID standard documents.

JW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
December 30, 2019

> Is it possible to read state of capslock on/off with stm

No, but this is regardless of whether "with stm" or without. The USB keyboard is completely state-less - it reports which keys are currently pressed, and CAPS LOCK is not different from any other ordinary key. It's the host which has to maintain the CAPS-toggle state, if it implements that at all.

Similarly for LEDs - there is no way to read out the state of LEDs from the keyboard (it even may not implement the LEDs at all). This is even explicitly stated in the standard (HID1.11) in Appendix C:

Synchronization between LED states and CAPS LOCK , NUM L OCK , SCROLL L OCK ,

COMPOSE , and KANA events is maintained by the host and NOT the keyboard

Read the respective USB HID standard documents.

JW

November 20, 2021

Actually yes. It is possible to read and write memory from the keyboard LEDs. I just tested it, see the code:

https://community.st.com/s/question/0D53W00000FNNDF/usb-host-keyboard-output-report-how-to-control-the-3-leds-numlock-caps-lock-and-scroll-lock-status

November 20, 2021

Actually yes. It is possible to read and write memory from the keyboard LEDs. I just tested it, see the code:

https://community.st.com/s/question/0D53W00000FNNDF/usb-host-keyboard-output-report-how-to-control-the-3-leds-numlock-caps-lock-and-scroll-lock-status