1

I connected two different keyboard to my computer. (Both use USB port to communicate with the computer.) The question is:

Why when I press Caps-Lock or Num-Lock in one keyboard, The related light (The LED on the keyboard) on the other one turns on and turns off also!?

As @Tetsujin mentioned in the first comment, I guess the computer receive the request from one keyboard, and send the answer broadcasting to all ports.If so, why? Doesn't have each port a specific address to send answer just for that address? Doesn't this current mechanism increase vulnerability? (For example a hardware keylogger)

1 Answers1

5

Windows only accepts one keyboard at a time (without specialized driver software), so the interactions with one keyboard affect all keyboards. Although you can plug multiple keyboards in and the all work, they are all dealt with through the same single interface in the OS, and are all treated equally.

The keyboards themselves only send key-codes to Windows tell it which key is pressed, all keyboards send the same key-codes (in general), and it's up to the OS (Windows) to decide what to do with them. Because of this, the OS actually controls the state of the modifier keys like Caps and Num.

Since all attached keyboards are affected the same, the OS updates all keyboards to be in the same state when Caps lock (etc.) is toggled, regardless of which Caps lock key was used.

You can expand on the effect by turning on the Windows onscreen keyboard. You'll note its visual key-presses reflect the modifier keys (shift, control, alt, Caps lock, etc.) you press on your physical keyboard(s).

For further reading, perhaps check out these other SU questions: