How does a USB keyboard work?
Ben Eater7 HN recommenders · recommended in 6 months, 2021-2025
3.8M views · 5 years ago · tutorial · evergreen
Ben Eater explains how a USB keyboard communicates, covering the electrical interface, bit and packet encoding, packet contents, and a comparison with PS/2.
HN commenters recommend it as a clear, comprehensive explanation of USB signaling and keyboard polling.
33:07So how does a PS/2 keyboard interface work?
Ben Eater
570K views • 5 years ago
11:23How a transistor works
Ben Eater
847K views • 11 years ago
6:538-bit computer update
Ben Eater
2.8M views • 10 years ago
28:43Why build an entire computer on breadboards?
Ben Eater
3.4M views • 6 years ago
27:528-bit CPU control logic: Part 1
Ben Eater
1.5M views • 9 years ago
27:25“Hello, world” from scratch on a 6502 — Part 1
Ben Eater
5.9M views • 7 years ago
13:02Making logic gates from transistors
Ben Eater
3.1M views • 11 years ago
32:47The world's worst video card?
Ben Eater
7.1M views • 7 years ago
41:04Design Your Own Keyboard!
Ben Vallack
140K views • 4 years ago
16:25Converting devices to USB Type-C
DIY Perks
8M views • 6 years ago
27:55E-paper hacking: fastest possible refresh rate
Applied Science
582K views • 9 years ago
24:23World's worst video card? The exciting conclusion
Ben Eater
3.2M views • 7 years ago
2:50:28(Sponsored) KiCad STM32 + USB + Buck Converter PCB Design and JLCPCB Assembly - Phil's Lab #11
Phil’s Lab
1.2M views • 6 years ago
1:40:06KiCad 6 STM32 PCB Design Full Tutorial - Phil's Lab #65
Phil’s Lab
987K views • 4 years ago
14:39How to power ANYTHING using USB-C Power Delivery and the ZY12PDN PD Trigger Board
Kenneth Finnegan
322K views • 6 years ago
2:48Series circuit - 3 LEDs
Henryk Gasperowicz
620K views • 14 years ago
44:31BadUSB - On Accessories that Turn Evil by Karsten Nohl + Jakob Lell
Black Hat
147K views • 12 years ago
35:33How does Computer Memory Work? 💻🛠
Branch Education
5.5M views • 4 years ago
17:15The Art of the Bodge: How I Made The Emoji Keyboard
Tom Scott
3.5M views • 11 years ago
44:50My personal fight against the modern laptop
linux conf au 2017 - Hobart, Australia
121K views • 9 years ago
12 comments from Hacker News
Serial ports still exist today. Even in desktop computers (though usually in weird underpowered ones designed for industrial applications and such). Even the most GAMING of motherboards have headers ready for one or even more serial ports to mess with. All you need is a cable and a card to slot into a PCIe bracket! USB itself, at least the 1.1 protocol that's still used for some devices today, isn't all that complicated in itself: ▶ this video Many if the complicated parts here, like device identifiers, are the things you'd need to manually configure if you were to use a serial port. Those hundreds of pages are similar to the hundreds of device types, vendors, and models that Windows would list when you clicked "add new hardware" back in Windows 98. When push comes to shove, you're just sending energy pulses down wires, there's just a chip in there that helps collect pulses so you don't need to manage the timing manually.
Among other things, the USB host polls the keyboard at a fixed rate. Fantastic breakdown if you have 30 minutes: ▶ this video
PS/2 Keyboards are faster than a USB keyboard with slow-speed negotiation with the host computer but for USB keyboards with high speed negotiation, they are at par[1] [1] ▶ this video
Ben Eater has some videos showing the USB protocol on an oscilloscope. ▶ this video link And some videos on using chips and breadboards to meet protocols- link And a digital protocol too- link
If you're interested, here's a really comprehensive video on how USB keyboards work which may answer your question: ▶ this video
I'm sorry but serious question, why would you need a high-speed for a keyboard? A usb packet for a keystroke is roughly 180 bits (I'm estimating from glancing at ▶ this video ). So 1.5 Mbit/s low speed could roughtly handle over 8,000 keystrokes per second. Do you really need more keystrokes or finer resolution than that?
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: ▶ this video
> Embedded programming? Dealing with signals?! God forbid, man. "How does a USB keyboard work? by Ben Eater: * ▶ this video
I'd imagine it would be very difficult, and would require a relatively powerful MCU. Ben Eater's made a few videos discussing how PS/2[0] and USB keyboards[1] work. USB's a vastly more complicated protocol compared to PS/2. [0] link [1] ▶ this video
Apparently [1] PS/2 limited by a slower data rate than USB 2.0 which cancels out almost all the advantage of its lower initial latency to begin the transmission, making them both about equally capable in actual latency - at least in theory. [1] ▶ this video Even if this conclusion is wrong, that video is a very pleasant and understandable explanation of the USB protocol.
There’s a great video here that goes through all this - the gist is that USB keyboards specify what polling rate to use, 1000hz for the best ones, maybe 125hz for the cheaper ones. An interesting thing about ps/2 is that even though it doesn’t have to wait for the keyboard to poll it transmits data at much slower speed than USB (khz vs mhz) which somewhat offsets the advantage it gets from being interrupt driven ▶ this video edit: ah, sorry, I see someone's posted a link to this video already!
Piggy-backing this comment to add some context for the OP video: This "USB device discovery" video is actually the latest in a series of videos where Ben Eater is building a simple 8-bit computer on breadboards. He hooked up a PS/2 keyboard as an input device, and then got sucked into a tangent of investigating and explaining keyboard protocols. - He investigates the PS/2 keyboard protocol: link - Somebody on Patreon asked about USB keyboards having higher latency than PS/2, so he made a video about the basic USB protocol: ▶ this video - He made the OP video about USB keyboards being limited to holding six keys at once.