How does a USB keyboard work?

Channel:Ben Eater · Length:34:15 · Published:2021-06-05 · Views:3769645

Watch on YouTube

Summary

Ben Eater explains how a USB keyboard communicates, covering the electrical interface, bit and packet encoding, packet contents, and a comparison with PS/2.

Why HN recommends it

HN commenters recommend it as a clear, comprehensive explanation of USB signaling and keyboard polling.

Fantastic breakdown if you have 30 minutes — HN, 2024

Computer architecture & CPUs · Electronics & circuit design · Embedded systems & DIY electronics

Subtitles (excerpt)

the old ps2 style keyboard interface is pretty simple only four of the pins are actually used two of them are for ground and five volts to provide power to the keyboard and then once the keyboard is powered up the other two pins provide two signals that are used to communicate and each time we press or release a key the keyboard will send one or more of these bursts of data on those two signals and so each of these bursts includes 11 clock pulses and the corresponding data a start bit 8 bits of data a parity bit and a stop bit it really couldn't be a less complicated protocol and in fact over on patreon emily says i've heard anecdotally that ps2 accessories are better for gaming because the latency is lower than usb seeing how simple the protocol is i could probably believe that now maybe someday you'll hook your oscilloscope up to some usb gadgets and we can see how complex that is well that day has arrived i've got a usb keyboard here and the standard usb 2 connection also uses just four pins there's ground five volt power and then two data signals here that we can look at on the oscilloscope if we look at the spec we see red is bus voltage black is ground and then green or white are d plus and d minus so rather

On Hacker News

Among other things, the USB host polls the keyboard at a fixed rate. Fantastic breakdown if you have 30 minutes: [VIDEO] — ericbarrett, 2024-11
About the USB keyboard, that may be true only for the cheapest keyboard you could find, but basically not applicable anymore nowadays. Rather than giving you the details, let me link to this video, which is awesome at explaining it and much more -- the USB vs PS/2 part starts here: [VIDEO] — jordibc, 2022-03
Ben Eater has some videos showing the USB protocol on an oscilloscope. [VIDEO] [LINK] And some videos on using chips and breadboards to meet protocols- [LINK] And a digital protocol too- [LINK] — lozenge, 2022-09
If you're interested, here's a really comprehensive video on how USB keyboards work which may answer your question: [VIDEO] — jai_, 2022-06
> Embedded programming? Dealing with signals?! God forbid, man. "How does a USB keyboard work? by Ben Eater: * [VIDEO] — throw0101a, 2021-11

Related videos