There is also a complete library HID-Project by Nico Hood in library manager and on github: GitHub - NicoHood/HID: Bring enhanced HID functions to your Arduino!
And an example from that library to detect the caps lock key: https://github.com/NicoHood/HID/blob/master/examples/Keyboard/KeyboardLed/KeyboardLed.ino
Further you could have done some research as the subject has come a long a few times
1 Like