cy384

hardware / software / wetware

input latency

Keyboard latency is largely ignored by everyone except gamers (and marketers targeting gamers), but I find it's much of the subjective "feel" of an editor/OS/input device stack. I'm sure others have found working in a VM unpleasant for this reason. I want to look at a source of latency nobody else seems to have examined closely: switch travel (more specifically, "pretravel").

how bad is it?

Some people have examined latency of operating systems, text editors, and terminals, and some people have examined the switch actuation to userspace end to end latency (to examine keyboard firmware). To my knowledge, nobody has compared switches themselves. There are two latency-relevant parts of this:

filename

This graph by HaaTa shows force vs. distance of a standard switch used in mechanical keyboards: the Cherry MX Blue. Note travel at the actuation point (the pretravel): about 2.3mm. How long does it take to travel that distance?

how long!

We could measure this, but I don't have a high speed camera or a tiny accelerometer to stick on a key, or... anyway, let's estimate it with a simple model. The human's finger starts at x=0, t=0, v=0, and then a constant acceleration is applied until x=pretravel (for a Cherry MX Blue, 2.3mm). So what's the acceleration? How fast does a human finger accelerate on a keyboard? I polled IRC and the median guess was about 10g. I did a quick literature review and found a two possibly useful numbers:

For a Cherry MX Blue, pretravel takes (at 10m/s^2) about 21ms. If we instead use 140m/s^2, it takes about 6ms. For a standard laptop keyboard with pretravel of 1.5mm, at 10m/s^2, it takes about 17ms. At 140m/s^2, it takes about 5ms.

conclusion

With estimates of acceleration varying by 10x, this doesn't seem very useful. However, even if we pick the slower acceleration, the difference is about 4ms. With a "normal" end-to-end latency around 100ms, it's fair to say variance in switch travel is a modest portion of total latency. For anyone desperate for those last few ms, may I suggest Apple's much-maligned new laptops with a travel of 0.5mm? Or try out some finger exercises.

Dan Luu's keyboard latency tests imply to me that firmware is the largest factor in keyboard latency. In our context, however, we can look at two keyboards we may assume are well-programmed: Apple's low-travel membrane/scissor switch keyboard is measured as 10ms faster than Das's Cherry MX Blue keyboard. This seems to be in line with the added costs of debouncing time (5ms) + travel time (5ms), which approximately supports my estimate above.

I would like to see someone (else) do measurements specifically of pretravel time. If I revisit this topic, it will probably be focusing on measuring and optimizing firmware latency, rather than switch choice and pretravel.

further reading