Main Site Documentation

KBE using USBC_Keyboard is there a way to get current keyboard state?


is there a way to get the state of the keyboard
for example if I want to send a capital A. I need to know if to hold shift and then press a or not to.
in case capslock is on the shift will do the opposite than I want.
any way to get the state of the key?


Yes, check the documentation it has an example:

                    // We need shift down for capital "H"

                    // Now "ello world"


thanks but what I meant is how to know if specific keys are down
the example won’t work in case capsLock is on
then the example will type


and that is not what I want. I want it no matter what is the keyboard state to have printed
!Hello World


@ Devloper123 - USBC_Keyboard class is used when you want your device to emulate a keyboard when connect to a PC. USBH_keyboard is the class to use when you want to connect a keyboard to your device.


Are you sending or receiving keyboard events?


sending key strokes.
but want the result to be the same no matter what is the current state of the keys,


@ Devloper123 - I an confused. If you are sending from the MF device there are no physical keys. Please describe you configuration in detail.


I assume he’s referring to instances where there is already a keyboard attached to the system his board is connected to. He wants to ensure that if the other keyboard has caps lock on, it won’t affect his device – and if it will, he’d like to detect that.

I’ve never done USB HID with multiple keyboards, so I’m not sure – do operating systems maintain a global caps lock status that applies to every keyboard? Or does caps lock only apply to the keyboard that activated it?

I assume the latter would be the case.


@ jay - I would assume that the caps lock is local to a keyboard we not make assumptions, and get a better understanding what the OP is trying to do. :slight_smile: