69

When I slam my hand onto my keyboard, only a maximum of 6 keys will be registered, I've tested this for the past few minutes and was unable to get more than 6. Is this the same on all keyboards? If not, what would be the distinguishing factor, If yes: why 6 specifically?

For clarification: I do not have a usecase for this, I am simply curious

1
  • 1
    Comments are not for extended discussion; this conversation has been moved to chat.
    – DavidPostill
    Jun 8, 2019 at 15:12

4 Answers 4

90

Not all keyboards are like that. What you're referring to is called rollover or key rollover. This simply refers to a computer's ability to correctly handle several simultaneous keystrokes.

X-key rollover refers to how many keys you can press down at once, while still being registered by the computer.

I don't know if there is a standard "default" level, but many keyboards are 6-key rollover. There are some gaming and higher end keyboards that have true n-key rollover, which means each key is scanned completely independently by the keyboard hardware. This ensures that each keypress is correctly detected regardless of how many other keys are pressed down at the same time.

Depending on your keyboard, you could have the option to use 6-key rollover, or enable true n-key rollover. For example, I have a Deck Hassium Pro that has 6-key rollover by default, but there is a hotkey to enable true n-key rollover.

11
  • 70
    One reason for the 6 key limit: the HID specification requires that keyboards not report more than 6 keys at once to the BIOS (though the OS has no such limitations). See usb.org/sites/default/files/documents/hid1_11.pdf appendix B for reference. I suspect it's just that nobody wants to deal with having a BIOS mode and a "extended mode" with n-key rollover.
    – Andrew Sun
    Jun 6, 2019 at 0:05
  • 23
    @AndrewSun: Bizarrely enough, this is only a restriction with USB. PS/2 keyboards can support true n-key rollover without having to provide "Am I talking to the BIOS?" logic.
    – Kevin
    Jun 6, 2019 at 6:38
  • 5
    Does the n-key-rollover-hotkey work if you are already pressing six other keys when you hit it?
    – JDL
    Jun 6, 2019 at 14:18
  • 14
    @JDL that was harder than I thought to test, but the answer is yes.
    – DrZoo
    Jun 6, 2019 at 14:29
  • 8
    The claim that the HID specification requires this is really a myth. The boot report descriptor format does not support more than 6-key rollover (excluding modifiers). But that does not preclude the very thing that USB has designed in: alternative report descriptor formats. People can and do use those. unix.stackexchange.com/a/401773/5132
    – JdeBP
    Jun 6, 2019 at 19:28
56

Search for key rollover.

  • One limit occurs because most keyboards do not have individual wires for each key; instead the keyboard has a matrix (or several) where each key connects a specific row/column, and when too many simultaneous connections are made in the same matrix, they become impossible to distinguish.

    So the first number of simultaneous keys depends on how the keyboard's electronics were designed. Search "keyboard matrix ghosting" for quite a few articles on this topic.

  • If the keyboard's hardware avoids the physical issue, the other limit occurs due to the protocol used by USB HID devices – or rather, two protocols. To quote Wikipedia:

    For the user to get the benefit of the full n-key rollover, the complete key press status must be transmitted to the computer. When the data is sent via the USB protocol, there are two operating modes: Human Interface Device (HID) "report protocol" and "boot protocol". The boot protocol, which is enabled on boot, is limited to 8 modifier keys [...] followed by maximum 6 key codes. This will limit the number of simultaneous key presses that can be reported. To get full n-key rollover, HID report protocol must be implemented on both keyboard and computer.

    (If you're sure the keyboard supports it, then it might be just a matter of switching the driver in Windows.)

1
  • 2
    The first problem can be solved by putting each key in series with a diode.
    – Paul
    Jun 6, 2019 at 9:20
2

Keyboards do not wire to each single key independently. Membrane keyboards use a sort of a sparse grid, which is just enough to tell which key is being pressed right now. Varying by the model, there's about 20 contacts between the membrane and the controller board, including the ground.

Every key being pressed or not is 104 bits of data per poll interval. If the membrane contained semiconductor components that could encode this data, it could send it to the controller. But the membrane is just a plastic film with a bit of silver tracing - a parallel analog interface that has no more capacity than its number of contact pins. The traces are placed such as to identify a couple keys being pressed simultaneously, plus the modifiers.

High-end keyboards are almost universally mechanical, built on a PCB, which supports active electronics at any place on the board. Early mechs included some 6KRO models, but the majority of mechanical keyboards today support NKRO, which means any number of keys will be registered simultaneously.

If you aren't prone to spills and look for guaranteed key registration, the way to go today is mechanical. (With spills, most back-lit mechanicals will die from the high current to the backlight hitting the controller.) There's a small segment that still prefers scissor membrane keyboards, and non-scissor membranes remain the second most spill-resistant practical keyboards after Topre's capacitor models, usually lumped in with mechanical ones.

2

Videos don’t make great answers on this site, but I nevertheless recommend How does n–key rollover work? by Ben Eater. He demonstrates the differences between a cheap keyboard with 2–key rollover and a good keyboard with n–key rollover, describes how the circuitry in these keyboards work to show what the cheap keyboard is missing, and captures actual USB setup and data packets from the keyboards to show exactly how they communicate with the host computer.

You can compare this with his earlier video So how does a PS/2 keyboard interface work? to see the differences between the USB and PS/2 protocols. He’s also got a couple of videos where he writes the software for a 6502–based computer to convert these key events into text.

What is most interesting about the PS/2 protocol is that nothing needs to change to accommodate n–key rollover, but only because it pushes a lot of the work onto the computer itself. The computer must have a buffer large enough to hold at least one key press event from each key on the keyboard, or it needs to translate those key press events into a bitmap of keys that are currently being pressed. On USB keyboards, the keyboard itself must maintain that buffer or bitmap. That buffer traditionally has room for six keys (though in principle it could be any length), which is long enough to satisfy most users, but not to support true n–key rollover. Some keyboards with less than 6–key rollover nevertheless have a USB chip with a six key buffer.

As an aside, the operating system on your computer delivers key–press and key–release events to the programs you are running, almost exactly like the PS/2 protocol delivers, so it must convert the buffer into six to twelve events. Likewise the bitmap could end up getting converted into more than a hundred events. Game engines frequently convert these events back into a bitmap of keys that are pressed¹ for the game to examine.

It’s basically clown shoes.

¹ Or sometimes a larger bitmap that indicates which keys started being pressed this frame, keys that have been pressed for multiple frames, and keys that were released this frame.

1
  • That video is great. It explains how NKRO keyboards need to switch to a different protocol because the standard USB protocol only allows for 6KRO plus modifier (shift,ctrl...) keys. It also goes into many gory details about the USB handshake and packets. It really answers the question in the best way possible. May 8, 2023 at 9:09

You must log in to answer this question.

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