Keyboard latency: where the delay comes from and how it is tested
Keyboard latency is the time from the moment your finger starts pressing a key to the moment the keyboard has sent that press to the computer. It adds up in four places: the key's travel, the keyboard scanning its keys, debounce and USB polling. No website can measure it, because a browser only hears about a press after the keyboard has sent it. Testers use a solenoid that presses the key and a USB analyzer that records when the press leaves the keyboard. To lower it, use a shorter actuation point, the highest polling rate and the lowest debounce setting that does not make keys type twice.
Where a key press waits before the computer gets it
- Key travelthe key moves down to the point where the switch fires
- Scanningthe keyboard's chip checks the grid of keys, row by row
- Debounceit waits for the switch contact to stop bouncing, or ignores the bounce
- USB pollingthe press waits until the computer next asks the keyboard for news
Together: keyboard latency
A web page can only start its clock here
Computer and screen the game uses the press, draws a frame and the display shows it: the rest of your input lag
Where the delay comes from
- Key travel. Nothing happens until the key reaches its actuation point. Filmed at 240 frames a second, a normal key press took 4 to 8 frames to go all the way down, and the travel alone can easily add 10 ms. The quickest keyboard in that test also had by far the shortest travel.
- Scanning. Most keyboards wire their keys in a grid and check it row by row. A keyboard that scans slowly can see your press several milliseconds after the switch closed.
- Debounce. A switch contact bounces for a moment when it closes. The keyboard either reports the press at once and ignores the bounce, or waits until the contact has settled. In QMK, the open-source firmware many custom keyboards run, the default debounce time is 5 ms.
- USB polling. The computer asks the keyboard for news at its polling rate. A press made just after a poll waits for the next one.
Polling rate in milliseconds
The time between two polls is 1,000 ms divided by the polling rate. On average a press waits half of that.
| Polling rate | A poll every | Average wait |
|---|---|---|
| 125 Hz | 8 ms | 4 ms |
| 250 Hz | 4 ms | 2 ms |
| 500 Hz | 2 ms | 1 ms |
| 1000 Hz | 1 ms | 0.5 ms |
| 8000 Hz | 0.125 ms | 0.0625 ms |
Going from 125 Hz to 1,000 Hz saves 3.5 ms on average. Measured keyboards differ by far more than that: in 2017 Dan Luu measured 21 keyboards at 15 to 60 ms, and the two gaming keyboards among them were not faster than the others.
How keyboard latency is tested
- A solenoid and a USB analyzer. RTINGS and LTT Labs press the key with a solenoid, mark the moment it touches the key, and record with a USB analyzer when the press leaves the keyboard. RTINGS averages 200 presses. Both set the keyboard to its fastest settings first, such as the lowest debounce and the highest polling rate.
- Each connection on its own. LTT Labs measures cable, 2.4 GHz wireless and Bluetooth separately, because the latency can change a lot between them.
- A logic analyzer. Dan Luu used one to time the gap between the start of a key press and the USB packet it produced.
- At home, a camera or a light sensor. Film the key and the screen together in slow motion (240 frames a second is a frame every 4.2 ms), or use a light sensor on the screen such as the open-source OSLTT. Both time the whole chain from key to screen, not the keyboard alone.
Why no website can test keyboard latency
A browser learns of a key press only after the keyboard has sent it and the computer has passed it on, so everything this page describes has already happened before a web page can start a clock. A test that times you from a signal to your key press measures your reaction, which takes far longer than the keyboard. What a browser can check is whether every key registers and how many work at once, on the keyboard test, and whether a key types twice, on the double press test.
How to lower keyboard latency
- Set the highest polling rate in the maker's app, if it offers one.
- Lower the debounce, if the app lets you, but stop at the lowest setting that does not make keys type twice. If letters start doubling, see why a keyboard types double letters.
- Use a shorter actuation point. Magnetic and analog keyboards let you set how far a key goes down before it counts. Rapid Trigger, on keyboards such as Wooting's, also lets a key go the moment you start to lift it, and press again the moment you push back down.
- Pick the fastest connection for games. If your keyboard connects more than one way, use the one a review measured fastest.
- Then look at the rest of the chain. Your frame rate and your display usually add more delay than the keyboard: see how to reduce input lag.
How linear, tactile and clicky switches differ, with the makers' figures for actuation point and force: keyboard switches.
Sources: Dan Luu, Keyboard latency; RTINGS, Keyboard latency test method; LTT Labs, How Labs conducts keyboard testing; QMK, Debounce algorithm; Wooting, How to set up Rapid Trigger; OSLTT, Open Source Latency Test Tool.