Keyboards: the computer doesn't write what I typed. Why?

Keyboards usually check the key presses by contact of wires in a matrix. The controller only sees contacts at matrix coordinates and, therefore, can reliably handle in worst case two independent keypresses. Two-key rollover (2KRO) means that: minimum two keys at once recognized. 2KRO is a must for fast typers that may press the next key before releasing the first. But all gets worse when it comes to typing with Shift pressed for uppercase; while manufacturers should keep the modifiers in separate contact lines to the MCU (Microcontroller Unit), most of them will have the modifiers in the matrix for low quality keyboards. This makes the keyboards type wrong when the fast typist writes uppercase characters with shift pressed, where letters effectively work as a only-one-key-at-once (1KRO) keyboard.

Also many keyboards sample the key presses at 125Hz which is quite low for fast typing. Even if sustained typing may be about 600presses/minute (100Hz) often two specific keys can be pressed in less than 125Hz period. Then the keyboard doesn't know which key was pressed first.

Many keyboards also implement only a basic USB keyboard protocol (named boot protocol) that allows reporting at most 6 pressed keys at once (modifiers apart in a bitset), but this is a problem only for gamers, not for fast typers. Keyboards can implement a HID device beyond the boot protocol and report more keys at once.

One problem is inherent to the USB protocol though; only regular the keypresses are communicated to the computer in order. The press of the modifiers is a bitset that is communicated in every message and, therefore, cannot be ordered with the other keys.


Tests to evaluate your keyboard

Things valuable to test for fast typing.

Test bad keyboard 1. Press Shift + two letters at once.

Check if shift + any-two-letters are recognized before releasing them.

Example sequence from Logitech K120. Type TR uppercase like this:

Step Key change Total pressed Screen Expected
1 ↓RightShift ↓RightShift
2 ↓T ↓RightShift,↓T T T
3 ↓R ↓RightShift,↓T,↓R T TR
4 ↑RightShift ↓T,↓R Tr TR

Other keyboards hit this problem in different letter pairs, like BV, FG, etc. Some others will be able to respect the uppercase for the second letter.

Test bad keyboard 2. Press two keys in sequence very fast

Drop two fingers fast to two letters, caring to know what key you hit first. Repeat it many times and check the reliability changing which you press first.

Example with the Logitech k120:

  1. Type MK many times in a row, with the two fingers drop down
  2. Result on screen: mkmkmkmkmkmkmkmkmkmkmk (good)
  3. Type KM many times in a row, with the two fingers drop down
  4. Result on screen: mkkmmkmkmkmkmkmkmkmkmk (often swaps to mk)
If you check the timestamp of the key arrival you may notice that both letters arrive at the same timestamp when the keyboard was confused. In the test bench below you will see a "Fastest interkey time" of around 0ms. At least in some firefox on GNU/Linux. Other browsers/OSes can give timestamps taken at other moments.

Test bad keyboard 3. Check USB HID Report frames

PS/2 keyboards send key change one after the other, either press or releases, so they are always received in a particular order. But unlike the PS/2 protocol, the USB messages allow to notify more than one keychange (press/release) in a single frame, at the expense of somewhat unclear order. Non-modifier presses are always ordered, but releases or modifier press/release are optionally without order. Some devices (keyboards or PS/2-USB converters) choose to clarify the order by guaranteeing a single key change between any message. As a note, most notebook keyboards use a PS/2 link, not USB, so this would not apply to them.

Use the GNU/Linux usbhid-dump program to dump the frames and see if they send a report for every key change or they integrate multiple into one. Run it with timeout 10 usbhid-dump --entity=stream so after 10 seconds you will be able to rule your computer again.

Report format: The first byte indicates the state of modifiers; every bit is a modifier. The second byte is reserved. The next bytes indicate keycodes pressed, in the order they were pressed.

Example from Logitech K120. Frames at most every ~16ms, unclear order of some key changes.

Timestamp Report Key changes Meaning
2.368963 00 00 00 00 00 00 00 00 No keys pressed
2.857024 00 00 13 12 00 00 00 00 ↓P and then ↓O. Clear order. Text typed: po
3.065040 00 00 00 00 00 00 00 00 ↑P and ↑O. Unclear order.
7.416589 20 00 0E 00 00 00 00 00 ↓Shift, ↓K. Unclear order. Text typed: K
7.600590 20 00 00 00 00 00 00 00 ↑K
8.032190 00 00 0C 00 00 00 00 00 ↑Shift and ↓I. Unclear order. Text typed: i. Some drivers may interpret it as I.

Example from Genesis RX55. Frames every ~2ms, clear order of all key changes:

Timestamp Report Key changes Meaning
0.000000 00 00 00 00 00 00 00 00 No keys pressed
0.408564 20 00 00 00 00 00 00 00 ↓Shift
0.432564 20 00 0E 00 00 00 00 00 ↓K Text typed: K
0.520562 20 00 0E 0C 00 00 00 00 ↓I Text typed: I
0.696566 00 00 0E 0C 00 00 00 00 ↑Shift
0.712568 00 00 0C 00 00 00 00 00 ↑K
0.736567 00 00 00 00 00 00 00 00 ↑I

Test yourself

In the test bench below you can test the speed of your typing.

Test bench

Note if you use Tridactyl: Use shift-insert to avoid commands. ESC to reset.

Keyboard:


Keys now pressed:
Rollover:
Text:
Presses/min:
WPM:
Fastest interkey time (ms):
Sequence:


Reports of what I tested

Keyboard 2KRO and Shift (Test 1) Quick two presses (Test 2)
Logitech K120 Shift+RT (T doesn't appear). Shift+RT_ (then releasing, types R_T. ES layout)). Also wrong release of shift: when Shift+TR is pressed and then shift first released, produces Tr. jk fast enough produce kj. s+space produces space+s. 12 produces 21.
Genesis RX55 (broken link) Shift+FG doesn't type G until F released. Also, Shift+RTE (then release shift and R) types RTe. perfect
Genius Smart KB-100 tre (then releasing in order, types tr, forgets e) (not tested)
Cherry Stream 3.0 Shift+VB doesn't type B until V released (iirc; if not these, other pairs of letters) km fast enough produce mk (worse than K120)
HP Probook 430 G4 (notebook) good 2KRO; shift allows any two character pairs at once. km fast enough produces mk (like Cherry Stream 3.0)
Toshiba C55 (notebook) perfect perfect
Acer 4810T (notebook) shift+FG accepts G after releasing F. perfect
Dell XPS 15 9550 (notebook) Shift+BV doesn't take the V. Releasing shift types V at least, not v. Pressing km sometimes types mk. Slightly better than K120 though.
Digital RT2158TWSP (PS/2) Shift+BV doesn't take V. Releasing shift types Bv. perfect
Innobo KB-930 (PS/2) Shift+FG doesn't take G. Releasing shift types FG fine. perfect
Logitech G213 "rov" all pressed doesn't send the v. "rova" all pressed and released in order sends "roav". perfect
HP H3C52AA Shift-FG doesn't take G. Releasing shift types Fg. km easily types mk
Microsoft Wired 600 Shift-BV doesn't take V. Releasing shift types Bv. perfect
Hama Washable Keyboard COVO Shift-FG doesn't take G. Releasing shift types Fg. perfect
Hama Basic Keyboard K212 Shift-FG doesn't take G. Releasing shift types Fg. km easily types mk
Cherry RS 6000 M (PS/2) Shift+VB doesn't type B until V released (iirc; if not these, other pairs of letters) km fast enough produce mk (worse than K120)
Labtec Media Keyboard HD844L1 (PS/2) Shift+VB doesn't type B until V released. Releasing first Shift produces Bv. perfect
Logitech Internet Keyboard 867227-0104 Shift+Any keypair seems to work fine Fast km writes mk
LG MK101 Shift+FG doesn't take G. Releasing shift types Fg. Fast km writes mk
Lenovo Z50 (laptop) Shift+BV doesn't take V. Releasing shift types Bv. perfect
HP PR1101U Shift+GF doesn't take F. Releasing shift types FG. Fast mk writes km
HP KU-1060 perfect Fast mk writest km
HP KU-1156 perfect Fast mk writest km
Logitech G110 gaming perfect Fast mk writest km
HP 434820 KU-0316 (PS/2) Shift+BV doesn't take V. Releasing shift types BV. Pressing ROVA and then releasing produces ROAV. perfect
HP 435382 KU-0316 (USB) Shift+BV doesn't take V. Releasing shift types Bv. Fast km writes mk. Worse than K120.
Samsung SEM-DT35 (PS/2) Shift+AB doesn't take S. Releasing shift types AS. perfect
IBM Mechanical 1391405 1990-06-06 (PS/2) Shift+BV doesn't take V. Releasing shift types Bv. All others 2KRO. fast km writes mk. Better than K120.
IBM Membrane 71G4638 1995-09-29 (PS/2) Shift+BV doesn't take V. Releasing shift types Bv. All others 2KRO. fast km writes mk. Better than K120.
HP Compaq nx6325 (laptop) perfect Fast km writes mk

Reports I heard


Based on: gadzikowski.com/nkeyrollover.html

Also related: Scan rate estimator for presses of same key