Why can my keyboard only digest 6 keypresses at a time?

66

6

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

Folling

Posted 2019-06-05T15:06:40.083

Reputation: 673

1

Comments are not for extended discussion; this conversation has been moved to chat.

– DavidPostill – 2019-06-08T15:12:32.097

Answers

89

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.

DrZoo

Posted 2019-06-05T15:06:40.083

Reputation: 8 101

66

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 https://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 – 2019-06-06T00:05:47.700

22@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 – 2019-06-06T06:38:34.137

5Does the n-key-rollover-hotkey work if you are already pressing six other keys when you hit it? – JDL – 2019-06-06T14:18:20.970

14@JDL that was harder than I thought to test, but the answer is yes. – DrZoo – 2019-06-06T14:29:21.757

2@Kevin I'm not sure, but I suspect that's because the OS reads the PS/2 port directly, instead of it being interpreted first by the BIOS -- then the only limit would be what the OS supports, which (in every case I know) is n-key. – Fund Monica's Lawsuit – 2019-06-06T15:14:12.397

7

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. https://unix.stackexchange.com/a/401773/5132

– JdeBP – 2019-06-06T19:28:28.910

@JdeBP "alternative descriptor formats" sounds like "in order for a keyboard to report more than 6 keys, it must not act like a keyboard" – Agent_L – 2019-06-07T12:30:07.133

It may sound like that to someone who does not understand USB, but that is not in any way an accurate description. – JdeBP – 2019-06-07T14:38:18.570

1@Kevin The fact that PS/2 natively supports NKRO, in addition to the fact that its signaling is interrupt-based rather than polling-based (USB uses a 5kHz polling frequency, I believe), enabling lower latency makes it superior to USB keyboards for gaming. I believe this is because PS/2 keyboards are stateless and send an independent signal whenever a key is depressed or released, whereas USB keyboards have to keep track of the keyboard state and periodically send updates to the OS, telling it which keys are currently depressed. – forest – 2019-06-08T02:36:31.587

@NicHartley No modern operating system requires keys to be interpreted by the BIOS. The days of operating systems using BIOS drivers is long over. After the OS is initialized, the BIOS might as well not even exist. Even on older BIOSes before UEFI (or UEFI in CSM mode), you could safely overwrite the first 512 bytes of memory, destroying the IVT (Interrupt Vector Table, which serves a similar function to an OS's IDT), and the OS would not care at all unless you're jumping back into real mode. – forest – 2019-06-08T02:38:05.160

@forest (Re BIOS): You're technically right, but although the OS is not dependent on the BIOS, it is doing the same thing that the BIOS would be doing (in most cases), since the average keyboard manufacturer is unwilling to implement two entirely separate modes of operation when they can get away with just doing the BIOS protocol. – Kevin – 2019-06-08T03:28:09.427

57

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.)

user1686

Posted 2019-06-05T15:06:40.083

Reputation: 283 655

2The first problem can be solved by putting each key in series with a diode. – Paul – 2019-06-06T09:20:37.380

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.

COVID-20

Posted 2019-06-05T15:06:40.083

Reputation: 121