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)

6
  • 1
    Presumably, the keyboard says "I pressed a button." The computer decides which it was & what that implies. It then says back to the USB bus "My CapsLock is now on, please handle that." The receivers [both keyboards] switch on the appropriate light. In short, the keyboard does not decide for itself what the state of CapsLock is, the computer does.
    – Tetsujin
    Commented Dec 31, 2014 at 11:10
  • @Tetsujin Why the computer broadcast its message to the USB ports? Doesn't have each port a specific address? If so, broadcasting doesn't build a vulnerability(key loggers)? Commented Dec 31, 2014 at 11:12
  • 1
    The keyboard has no way of knowing what the caps lock state is. Only the computer knows that for certain. If you press an 'A' there is no reason for the computer to say anything back down the Bus, but CapsLock or NumLock change a running status.
    – Tetsujin
    Commented Dec 31, 2014 at 11:14
  • BTW, Why does windows broadcasting the answer of toggle-state request? Commented Dec 31, 2014 at 11:18
  • 2
    Are you sure you're asking the question you actually want the answer to? Or should it be more along the lines of "Why can't I type in upper case on one keyboard & lower case on the other?"
    – Tetsujin
    Commented Dec 31, 2014 at 11:33

1 Answer 1

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:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .