2
\$\begingroup\$

This is a theoretical question. I want to ask, is the the modern keyboards communicate with PC such as wireless keyboards can 'get/read' some data from the PC? If not, what do I need to do for that? I assume it must have a receiver. Is there any protocols for that?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ What data is needed by the keyboard from the computer? None as far as I can tell. \$\endgroup\$
    – Andy aka
    Commented Aug 7, 2018 at 11:28
  • 1
    \$\begingroup\$ @Andyaka Although this doesn't seem like a good EE.SE question, I wanted to mention that some keyboards have LEDs that can be controlled by software on the computer. \$\endgroup\$ Commented Aug 7, 2018 at 11:31
  • \$\begingroup\$ @ElliotAlderson are you sure about that? LEDs such as num-lock and caps-lock are controlled by the keypad. \$\endgroup\$
    – Andy aka
    Commented Aug 7, 2018 at 11:33
  • \$\begingroup\$ @ElliotAlderson Does such keyboard is controlled wireless? \$\endgroup\$ Commented Aug 7, 2018 at 11:50
  • \$\begingroup\$ @Andyaka Yes, I use Linux and the xset command lets you control the keyboard LEDs. I usually remap the Caps Lock key via software, and once I do that the Caps Lock LED doesn't come on when I press the key. I don't know if it works on other operating systems or on all keyboards but there is at least one example of communication from the computer to the keyboard. I don't have a wireless keyboard so I can't comment on how they communicate. \$\endgroup\$ Commented Aug 7, 2018 at 15:45

2 Answers 2

3
\$\begingroup\$

Most modern keyboards use a USB interface. Likely they are using the HID protocol within the USB families of protocols. There is support for 2 way communications within the HID protocol. Some keyboards may take advantage of this so that the computer can control keyboard indicator lights. Some wireless keyboards use a Bluetooth interface. Bluetooth, like USB, has a definition for the HID protocol. There are also vendors using proprietary protocols. We can assume there is some 2 way communications as inferred by features such as battery level monitoring.

\$\endgroup\$
5
  • \$\begingroup\$ Wouldn't battery level monitoring be from the keyboard to the host too? Why would duplex comms be required for that? \$\endgroup\$
    – Transistor
    Commented Aug 7, 2018 at 12:39
  • 1
    \$\begingroup\$ Just the fact the keyboard is USB means it communicates in both directions. Otherwise it could not undergo USB enumeration. Beyond that, the HID (Human Interface Device) protocol within the USB protocol is for any USB/HID device. A keyboard, a mouse, ect and allows communication with the device. Here is a stackexchange q/a w.r.t. using Python on a RPi to communicate to a HID. \$\endgroup\$
    – st2000
    Commented Aug 7, 2018 at 12:48
  • \$\begingroup\$ I'm aware of that but the question is about wireless keyboards. \$\endgroup\$
    – Transistor
    Commented Aug 7, 2018 at 13:09
  • \$\begingroup\$ @Transistor -- wireless keyboards generally use a USB wireless receiver or bluetooth. At the very least, USB devices communicate to enumerate and bluetooth to pair. \$\endgroup\$ Commented Aug 7, 2018 at 13:38
  • \$\begingroup\$ I hadn't considered Bluetooth keyboards probably because I've never seen one. They would, of course, have bidirectional communications. Thanks. \$\endgroup\$
    – Transistor
    Commented Aug 7, 2018 at 15:47
1
\$\begingroup\$

Communication Protocol

I doubt there will be some communication protocol for lost or corrupted messages (key strokes). The communication speed can be very low, and the distance is mostly not more than a few meters at max.

In case there is some scroll wheel than more information is needed, but also this will be a quite low amount of data to be sent.

LEDs

Also, if there are LEDs (for e.g. caps lock, num lock) these are controlled by keyboard only. They are not controllable from the PC (otherwise there would be communication needed from the PC to the keyboard.

Update

See Don Fusili's comments too... What I am talking above are the 'normal' keyboards as seen most. It seems most ARE capable of two/bidirectional communication, but most do not use it.

For your question, the answer is, yes it is possible, but depends likely on the device driver what is supported.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Just like Andy aka's comments on the question: the LEDs on keyboards have not been necessarily controlled by the keyboard themselves for quite a while. I myself have two keyboards connected to my PC, one of which is wireless, whenever I turn on one of the locks on one, the appropriate LED on the other will light up. \$\endgroup\$
    – DonFusili
    Commented Aug 7, 2018 at 12:12
  • \$\begingroup\$ I never seen such keyboards, but of course it doesn't mean they don't exist, but these are special cases. Of course when there is anything controllable from the PC, than information needs to be sent to the keyboard as well. I updated my answer accordingly, thanks for the notification. \$\endgroup\$ Commented Aug 7, 2018 at 12:19
  • 1
    \$\begingroup\$ They have become the norm these days, see also: superuser.com/a/1234440 and superuser.com/q/362694 \$\endgroup\$
    – DonFusili
    Commented Aug 7, 2018 at 13:07
  • 1
    \$\begingroup\$ Sorry, you are wrong about the LEDs, at least in some cases. Linux allows you to control the LEDs via software. \$\endgroup\$ Commented Aug 7, 2018 at 15:47
  • \$\begingroup\$ True, that's why I added the update. I never seen it used (not even at Unix keyboards), but it seems it CAN be set. \$\endgroup\$ Commented Aug 7, 2018 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.