What is the expected behavior when holding down two keys on a keyboard?
Context
A friend and I are playing a game where the optimization to playing a given character in the game is to hold down two buttons at once, i.e. they keys Q and E. This would mean that within the game the two skills bound to these keys would go off alternatively.
I.e. when holding Q and E: Q E Q E Q E Q E Q E
Problem
The issue arises in that I am unable to replicate what my friend has done when I hold down the keys Q and E. What I get instead is:
ie. when holding Q and E: Q E E E E E E E E E
or E Q Q Q Q Q Q Q Q
(depending one which key is detected first)
After discussing with my friend, he says its n-key rollover in addition to anti-ghosting that allows this to work.
However, once both of us began to look deeper into this, it just made less and less sense since both of our keyboards has the aforementioned features. Both of our keyboards are listed below if it provides additional context.
- My friends: GMMK Full Brown Switch
- My Keyboard: Razer Hunstman Elite
What I'm trying to figure out now is what allows his keyboard to operate the way it does, while mine cannot do the same.
Anti-ghosting only comes into play when at least three keys are pressed — it's irrelevant for only two, so it doesn't matter here.
And for USB keyboards, key repeat behavior is dependent on software, not the keyboard. The keyboard simply tells the computer all of the keys that are held down at the moment (up to the "rollover" limit supported by the keyboard), and lets the computer know whenever that state changes. It's the OS that's responsible for comparing the list of held keys to the previous state and generating the appropriate "key pressed" and "key released" events, and it's the OS that's responsible for noticing when a key has been held down for a certain amount of time and generating extra events, if appropriate.
Every system I've ever seen behaves the way you describe your system behaving — typematic only generates repeats for the last key that was pressed, and only as long as it's held down (if you release that key, but still hold down other keys that were pressed earlier, there are no repeats at all). But since the behavior is defined by software, it should be possible to override it in software, as long as the keyboard is at least 2KRO (which basically all keyboards are; 1KRO would make proficient touch typing basically impossible).
In order to answer this question, one must understand how keyboards work.
If you look back to the earlier keyboards, you will realize that the plug has only a few pins on it, not the same number of pins as there are keys on the keyboard.
That said, if you press a key on the keyboard it is still instantly transfered to the computer without any delay. So how is this possible?
A keyboard works with a matrix of horizontal and vertical signals. All keys are layed out on a grid as shown on your keyboard. When you press a key down, it does not just say, key "x" is pressed down, but it will instead say, key on column 3 and row 5 has been pressed down. This means that in the end, the amount of data lines is not the number of keys, but only the number of rows and columns (optimized).
The problem now comes down when you press multiple keys at once, the matrix can now come in a state where it can't know for sure what key is pressed, which is why some keyboards can only press 2 keys at once and a 3rd key is ignored.
To combat this, the matrix has been redesigned to reduce this from happening, which is why some keyboards claim you can press 4 or 5 keys down, but if you find the magic combination, you get down to 2 again, but it happens far less frequently due to lots of trial and error.
Because this in the end still became a problem, other methods were used to actually support multiple keypresses, known as anti-ghosting. The problem here is that it can be achieved in many ways, which is why some keyboards give Q E Q E Q E, others do QEEEE or EQQQQQ.
So long story short, in an attemmpt to allow multiple keys to be pressed at once, depending on how much development budget and what method was used, the behavior of pressing multiple keys at once is different for different models.
Newer gaming oriented keyboards will send all keystrokes really fast to the computer, to the driver over USB which can tell the software what keys are pressed which shows QEQEQEQE, whereas older keys still use a matrix and use hardware keys, which only show QEEEEEEE or EQQQQQQ.