9 ms·
Keyboard Latency (2017)
- iamevn 5y agoI'm surprised by the section on including key travel time in the latency measures. Wasn't the Apple 2 keyboard about comparable in travel distance and resistance to today's typical mechanical keyboard switches? I still can't find it in me to like the Apple Magic keyboard because I feel like my fingers are smashing into a metal plate hundreds of times a minute. That's a me problem though and others just have better form. Now I'm curious about the latency of the stuff I've put on teensys in my own custom keyboards/controllers and will need to resist the urge to go shopping for a scope. Also wondering how much PS/2 vs USB matters.
- kongin 5y ago> I'm surprised by the section on including key travel time in the latency measures. Wasn't the Apple 2 keyboard about comparable in travel distance and resistance to today's typical mechanical keyboard switches? >>A major source of latency is key travel time. It’s not a coincidence that the quickest keyboard measured also has the shortest key travel distance by a large margin. The video setup I’m using to measure end-to-end latency is a 240 fps camera, which means that frames are 4ms apart. When videoing “normal" keypresses and typing, it takes 4-8 frames for a key to become fully depressed. Most switches will start firing before the key is fully depressed, but the key travel time is still significant and can easily add 10ms of delay (or more, depending on the switch mechanism). Contrast this to the Apple "magic" keyboard measured, where the key travel is so short that it can’t be captured with a 240 fps camera, indicating that the key travel time is < 4ms. Yeah, I don't get that either. It should be the time a key makes contact to the time the signal is sent. If I were to design that I would make an external trigger that connects to the solder pads of the key and start the timer on the logic analyser. I like my keys with a lot of travel and a good thunk when they send the signal. This would penalize them extensively for doing exactly what I want. I mean if you want fast keyboards capacitive key caps would be even faster, but I've yet to meet anyone who has replaced their keyboard with a tablet.
- regularfry 5y agoBecause typing on a capacitive tablet would be tiring. You can't rest your fingers anywhere without registering a touch, so you lose all the benefits of a home row. You need to be able to distinguish between resting contact and a positive press, and capacitives would make that hard. Not impossible, but not easy either, and tablets today don't do it.
- kongin 5y agoNot sure what you're explaining? I'm just pointing out that their metric is extremely flawed and can be easily gamed by an inferior solution. Like the Apple Magic.
- riversflow 5y agoI'm not seeing how its "gaming the metric" to include travel time of the key on a keyboard. Typing is ultimately a physical interaction with an interface, not just data transmission over a wire. Therefore, if we are measuring the latency of the input we must include physical travel time. Consider an extreme example, if each "key" used a control lever, like the type on a tractor or used to control thrust in an airplane, we'll just say 90 degrees with a radius of 8", with a significant amount of linear activation force(relative to a keyboard). It wouldn't matter if the device had response time that was virtually instant when you reached the activation point, the input latency of this system would be so significant as to be impractical for most typing tasks. If anything excluding travel time would be gaming the metric.
- kongin 5y ago>I'm not seeing how its "gaming the metric" to include travel time of the key on a keyboard. Because if we remove travel time by using a capacitive keyboard you end up with something that is objectively a worse keyboard. Replacing the capacitors with strain gauges so you can rest your fingers on the home row without activating them results in an worse keyboard yet again. Any metric that when optimized produces an objectively worse product is a bad metric and optimizing a bad metric is gaming it.
- Agingcoder 5y agoI agree with you about the apple magic keyboard. It hurts quite badly!
- bschwindHN 5y ago> Also wondering how much PS/2 vs USB matters. Ben Eater has a great video on this: https://www.youtube.com/watch?v=wdgULBpRoXk https://www.youtube.com/watch?v=wdgULBpRoXk
- AussieWog93 5y ago>Also wondering how much PS/2 vs USB matters. I had to get to grips with the USB spec when designing my USB scope [1]. Adherence to the USB spec itself doesn't necessarily create human-perceptible latency; HID frames can be transmitted every 1 ms and could be parsed in a negligible number of CPU cycles on an embedded machine with USB-OTG and no operating system. Like everything, the noticeable lag appears because the application-layer software is going through 15 layers of abstraction rather than talking directly to the input device, and this can become as complex and bloated as it wants. [1] https://espotek.com/labrador/ https://espotek.com/labrador/ (In case you become unable to resist your scope urge :P)
- puzzlingcaptcha 5y agoThanks for sharing, that looks like a great hobbyist tool.
- AussieWog93 5y agoYou're welcome. Not going to pass up an opportunity to shill my business on HN. :P
- unwind 5y agoThanks for sharing. Micro typo alert on the Labrador landing page: "Everything was been" -> "Everything has been" or "Everything was", I guess. :)
- Ballas 5y agoA lot of time can be wasted with poor debounce implementations. Cherry switches claims <8ms bounce IIRC, but you only need to debounce one of the edges. So as soon as you see the key start bouncing, you know it is activated, so you can immediately register the press, then do debounce. That way you only delay the registration of the release. By using a shift register you can also minimize it to the actual bounce time, not a predetermined delay. I (personally) don't know of any commercial keyboards that implements it this way, but given that their software is closed source, it is very possible that some do use this algorithm.
- awelkie 5y agoNot only that, but the matrix scanning could be done via interrupts instead of via polling as is typically[0] done. An interrupt could fire on a level shift of any of the column GPIOs, then the MCU needs to search the rows to find the selected key. After the interrupt the MCU will need to poll until all the keys are released. So there's another source of latency that could be improved. I think the only source of polling left is in USB, but I think that's inherent to the USB protocol (someone correct me if I'm wrong here). Without the USB polling I think it would be possible to have key-press-to-USB-packet completely interrupt driven which should make the latency in the keyboard itself negligible. [0]: I say typically but like you said a lot of implementations are closed source, so who knows. All of the discussions I've seen on matrix scanning use the polling method, and the open source implementations use polling as well (e.g. Keyberon[1]). [1]: https://github.com/TeXitoi/keyberon-grid/blob/master/src/bin/keyberon60.rs#L239 https://github.com/TeXitoi/keyberon-grid/blob/master/src/bin...
- Ballas 5y agoThe few open source implementations I have looked at scan the matrix as fast as the processor allows. So using interrupts can reduce power consumption a lot, but depending on the actual matrix layout, probably not any worthwhile speedup in the nominal case, as you still have to scan the rows after the interrupt. AFAIR, the USB poll rate is a function of USB rate, and what the endpoint reports/requests. Low-speed, full-speed and high-speed all have different poll rates.
- 5y ago
- wmwmwm 5y agoThere’s a great video here that goes through all this - the gist is that USB keyboards specify what polling rate to use, 1000hz for the best ones, maybe 125hz for the cheaper ones. An interesting thing about ps/2 is that even though it doesn’t have to wait for the keyboard to poll it transmits data at much slower speed than USB (khz vs mhz) which somewhat offsets the advantage it gets from being interrupt driven https://m.youtube.com/watch?v=wdgULBpRoXk https://m.youtube.com/watch?v=wdgULBpRoXk edit: ah, sorry, I see someone's posted a link to this video already!
- bborud 5y agoThat bit made no sense. It might have made some sense if it was measured from the moment you get physical feedback from the keyboard that the key has been pressed. But I suspect that this isn't as straight forward as it is tempting to believe. (For instance if the mechanical feedback and the moment of contact do not occur at the exact same moment)
- exmadscientist 5y agoSeeing this again makes me want to dig out the sketches I had for a FPGA-based keyboard controller. There's no poll latency when nothing is polled! (Okay, okay, there's a few clocks.) The trouble with that project was always that I hate prototyping with BGAs, having to deal with carrier boards sucks, and all the QFP or similar FPGAs were limited to 144 pins, which is just not quite enough for 108 keys given the number of other demands for I/Os, and the number of I/Os you actually get on a 144-lead package. I wasn't much looking forward to dealing with the USB either (I seem to remember it would require at least a small softcore?) but at least there's plenty of open or vendor implementations there to "borrow". If anyone wants to rip this off, go right ahead as long as you let me know... this controller was only one piece of a larger idea, and I love it when people do my job for me :)
- toast0 5y ago108 keys sounds like 4 keys too many to me, but I wonder if you could use multiple FPGAs and include a USB hub (soft or real), if you split the ten-key out, that might be enough to do the rest of the keyboard with a 144 pin chip, and the tenkey with a smaller chip.
- exmadscientist 5y ago> 108 keys sounds like 4 keys too many to me 108 includes 104 plus 4 media keys. I think there are also a few international layouts with more keys than US-standard, but I never got that far. > I wonder if you could use multiple FPGAs and include a USB hub (soft or real) That... is a recipe for pain. Complexity of small hardware projects is basically Ackermann in the number of processors you are coordinating.... Ideally in a product you really, really want only one firmware blob to update at a time. > if you split the ten-key out, that might be enough to do the rest of the keyboard with a 144 pin chip, and the tenkey with a smaller chip. I don't know if alt-codes would work with this strategy. Regardless, none of this is worth it just to avoid prototyping with a BGA or dev board. (I'm not even trying to avoid those for production; this is my day job so I'm not that afraid of big BGAs. I just don't want to ever have to solder or probe them, and the gods alone save you if you have to rework a joint!)
- charles_f 5y ago> That establishes the fact that modern keyboards contribute to the latency bloat we’ve seen over the past forty years Sometimes I try to imagine what things would be like if people were still trying to optimize their stuff as if it were to be ran on a 16mhz machine with a few kb of ram. Then I get back to the 6 electron apps I gotta work with, where latency between a key showing up in the search box and search results appearing gets close to 10s. Somehow things got wrong somewhere.
- cjonas 5y agoCould be worse. I've been doing dev on a citrix desktop, where a single keypress can take seconds to register.
- rubatuga 5y agoFuck Citrix, fuck RDP
- AnIdiotOnTheNet 5y agoDude, RDP is amazing. I'll take it any day over the typical *nix alternatives.
- ComputerGuru 5y agoRDP is insanely optimized and there a lot of hard science and math involved in making it work efficiently and effectively for dynamically changing content from steaming media to editing in a terminal and everything in between. However, the technology is constantly updating - if your experience is only with RDP from the days of XP, I can understand your frustration. Also, most third party (non-MSFT) products (servers or clients) don’t implement the full spec and stick to the bare-bones, high-latency, low-throughput v1 protocol which is still RDP thanks to MS dedication to backwards compatibility, and that will absolutely give you a subpar experience as well.
- DaiPlusPlus 5y ago> I've been doing dev on a citrix desktop, where a single keypress can take seconds to register. Why would that be slow, though? Citrix would only be like that if you were over a high-latency network connection - that's unavoidable. If it is a LAN connection then the Citrix box is overloaded: add more RAM and processor cores (and disable the page-file: disk IO is a big killer of VDI UX). The problem with the Electron apps mentioned is that it's a reflection of the sad state of affairs that we have crappy UX caused by bad technical decision-making, rather than a crappy UX just because the hardware is underprovisoned.
- smoldesu 5y agoThis has been posted here a few times, but one interesting exception is what systems these were tested on. The author prefaces their analysis by comparing a mysterious 'Kaby Lake' system with their Mac, then proceeds to crown the Apple HID as the winner. An easy way to cook the results would be to test the Apple peripheral on a Mac and run everything else on your Windows desktop. Frankly, the BSD I/O stack will destroy the one on Windows any day, so it would stand to reason that it might be more of a software bottleneck than a hardware one. I'm not accusing them of getting anything wrong though, I simply assume they aren't withholding any important testing info.
- ksec 5y agoMissing ( 2017 ) Previous discussion https://news.ycombinator.com/item?id=15485672 https://news.ycombinator.com/item?id=15485672
- sundvor 5y agoThe assertion that people don't preload mechanical keyboards when gaming is fairly ridiculous.
- DaiPlusPlus 5y ago"preload"?
- jhy 5y agoPush down a little bit
- anonymoushn 5y agoIn a lot of games like WoW or SC2 you need to press a lot of different buttons, to the point that it's not really practical to preload. In CS, maybe you can preload, but it would be nice to look at some footage and see if professional players actually do.
- deleted 5y ago[deleted]
- gnicholas 5y agoDoes anyone else experience massive latency with Apple's keyboard/case for iPad Pro? Mine is unusable in Pages (better in Notes), and often the first keystroke is missed, regardless of which app I'm in. Super annoying defect in an otherwise enjoyable keyboard.
- DaiPlusPlus 5y agoBluetooth keyboard? That could be due to the device having an aggressive auto-sleep setting.
- gnicholas 5y agoIt's actually physically connected, and the iPad can be charged through the keyboard/case's USB-C port.
- xlii 5y agoI recently switched to Ergodox keyboard and was wondering about latency since it felt like the keyboard had lag, but I attributed it to learning period. I was like - no way this is happening, since Ergodox is using USB cable whereas I used Apple's keyboard before. This seems to confirm my feeling. Interestingly, I think that it's highlighted the most in Slack which is slow enough bloatware to have a lot of latency already and those extra milliseconds just add up. The simpler the editor the smaller the impact I think.
- kohlerm 5y agoI assume your Ergodox is running QMK, which depending on some configuration values had a relatively slow debouncing mechanism. I think times were around 20ms. Checking https://www.youtube.com/watch?v=jWL4nU-vtWs https://www.youtube.com/watch?v=jWL4nU-vtWs which compares it with ZMK it seems like it is down to 8ms, but ZMK is still faster (1ms)
- scns 5y agoHave you contacted them about it?
- xlii 5y agoNot really as it's not that of an issue. It's just something I'm feeling and it can be attributed to many different factors - keyboard switch, key travel, software sluggishness. However bring 100+ WPM typer those couple ms could contribute to that feeling.
- helsinkiandrew 5y agoAwhile ago there was a submission and discussion on HN looking at the latency between a keystroke and something appearing on screen through the layers of OS and application, but I can't find it, anyone? And I thought human reaction time was 100-200ms+ anyway Or would training on a particular game/movement sequence improve that.
- lukastr0 5y agoReaction time is something entirely different from being able to notice latency. Read the article, it's addressed there.
- praptak 5y agoNoticing latency is very context sensitive. A fun example is drawing lines on a touchscreen. Even ~20 milliseconds manifests as a visible gap between the tip of the pen and the line that "chases" it. Temporal resolution of human hearing obviously varies with what exactly you measure but I believe it is in a single digit millisecond range for discerning between two clicks in quick succession and a single click.
- kragen 5y agoEven 1ms.
- 0-_-0 5y agoWhile participants performed dragging and scribbling tasks, very low levels of latency could be discriminated, i.e., ~1 versus 2 milliseconds [...] [0] [0]: https://www.semanticscholar.org/paper/In-the-blink-of-an-eye%3A-investigating-latency-Ng-Annett/386a15fd85c162b8e4ebb6023acdce9df2bd43ee?p2df https://www.semanticscholar.org/paper/In-the-blink-of-an-eye...
- kalleboo 5y agoYou may be thinking of the same guy, he has his earlier article[0] linked from this one [0] https://danluu.com/input-lag/ https://danluu.com/input-lag/
- dakra 5y agoMichael Stapelberg has a few interesting blog posts about keyboard input latency. His latest is at https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/ https://michael.stapelberg.ch/posts/2021-05-08-keyboard-inpu...
- jgb1984 5y agoWell, that's why I'm holding on to my decades old Cherry PS/2 keyboard. No polling, no latency, no ghosting, no key rollover issues. Unfortunately the PS/2 port is becoming rare, I'm limited to MSI for my upcoming AMD B550 motherboard because it's the only brand that offers it on a nicely specced ATX board.
- praptak 5y agoThere are PS/2 to USB converters but who knows what latency they add.
- jgb1984 5y agoUnfortunately the inherent PS2 advantages disappear when you use such a convertor afaik.
- exporectomy 5y agoApparently [1] PS/2 limited by a slower data rate than USB 2.0 which cancels out almost all the advantage of its lower initial latency to begin the transmission, making them both about equally capable in actual latency - at least in theory. [1] https://youtu.be/wdgULBpRoXk?t=1953 https://youtu.be/wdgULBpRoXk?t=1953 Even if this conclusion is wrong, that video is a very pleasant and understandable explanation of the USB protocol.
- kitsunesoba 5y agoI wonder how much CPU load changes the equation. I've experienced USB input locking up or stuttering as a result of high CPU load, which presumably wouldn't happen with PS/2.
- deleted 5y ago[deleted]
- KronisLV 5y agoIn case anyone is wondering about the keyboard prices, i looked through the list and also looked up the unavailable ones on the Internet. Here's their current prices at a glance, in USD: Keyboard Latency Connection Price (USD) chinfai silicone 35 USB FS 17 genius luxemate i200 55 USB 21 logitech k360 60 unifying 25 logitech k120 30 USB 29 easterntimes i500 50 USB FS 31 razer ornata chroma 35 USB FS 59 MS comfort 5000 40 wireless 71 kinesis freestyle 2 30 USB FS 89 apple magic (usb) 15 USB FS 99 das 3 25 USB 101 unicomp model M 30 USB FS 104 hhkb lite 2 20 USB FS 112 pok3r vortex 30 USB FS 129 filco majestouch 30 USB 129 topre type heaven 55 USB FS 149 olkb planck rev 4 40 USB FS 169 kinesis advantage 50 USB FS 319 ergodox 40 USB FS 354 MS natural 4000 20 USB 399 Personally, i have a Logitech K120 at home as a backup keyboard, and as far as membrane keyboards go, it's a solid and affordable choice. I'm not sure whether it's regional differences or something else, but i got my keyboard for about 10-15 euros. I guess the fact that it's extremely "boring" also adds to the charm, at least when compared to designs like Logitech K360. Also, i wish i could vouch for the Unicomp Model M keyboards, however shipping one to Europe would almost cost me as much as the keyboard itself and i'm currently not sure i can exactly afford to splurge like that. Regardless, have a look at their site, they're essentially carrying on with the legacy of IBM Model M keyboards in a way: https://www.pckeyboard.com/ https://www.pckeyboard.com/ From what i've seen while occasionally visiting their site, they also seem to introduce some new varieties occasionally. From what i've heard, those keyboards aren't exactly ideal for gaming (a regular mechanical keyboard might be better there), but are really good for typing because of their buckling spring design. LinusTechTips also had a video on the Model M keyboards a while ago: https://www.youtube.com/watch?v=D7wmMZmMinM https://www.youtube.com/watch?v=D7wmMZmMinM
- npteljes 5y agoI second the K120. I switched to it from my Das Keyboard Pro 4 after I got fed up maintaining it. The 3 key rollover is not ideal though, but otherwise I think it's solid - light to the touch, sturdy build, unassuming design, nothing weird going on with the layout.
- a-dub 5y agoi once was in an environment where keystrokes for everyday applications, like, windows instant messenger clients, traveled through three states with hundreds of millis of latency. i complained that this would make everyone slow and crazy. they didn't like the complaints and pushed back. i think they should have fixed it instead.
- kmisiunas 5y agoMore up to date keyboard latency tests: https://www.rtings.com/keyboard/tools/table/61322 https://www.rtings.com/keyboard/tools/table/61322
- anonymoushn 5y agoThese figures aren't really comparable because rtings subtracts out travel time.
- dijit 5y agoI have a hard time believing these, some even break the capability of USB.
- dsissitka 5y agoSee https://www.rtings.com/keyboard/tests/latency https://www.rtings.com/keyboard/tests/latency and https://www.rtings.com/keyboard/discussions/Wa2q1zEN8YG9OS9i/sub-1ms-latency-for-1000hz-boards https://www.rtings.com/keyboard/discussions/Wa2q1zEN8YG9OS9i....
- maxh- 5y agoI'm surprised that he includes the key travel time. If a keyboard maker claims low latency, I assume they mean from the point when the switch actuates, not when the keypress starts. It seems like he is mostly measuring travel distance and actuation point position, which are things you can find out without a high speed camera.
- smallstepforman 5y agoA repeat of my 2017 post for the original article. The issue not mentioned in the article is number of lines on the keyboard matrix used to detect keypresses. Cheaper non-gaming keyboards can only detect up to 4 simultaneous keystrokes. Gaming keyboards can detect up to 6. That may not sound like a significant difference, but if you're moving diagonally (eg. W and D), running (Shift), holding an item (or use) (E) and jumping (space), that is 5 keys which need to be processed. Moving from my older Gaming keyboard to a generic Logitec keyboard, and I was no longer able to run diagonally in FIFA games while doing trick moves. So the non gaming keyboard made me stop playing that game.
- vehemenz 5y agoThe feature you are talking about is called n-key rollover. Cheap keyboards generally don't have it. Similar to you, I discovered the issue in the 90s with FPS games. Keyboard manufacturers have been designed with n-key rollover as a feature since the late 70s, believe it or not. Keyboard technology has, in many ways, regressed since then. Fortunately, good keyboards are finally being made again—they just need to work on appearance and decent layouts again.
- Milkman128 5y ago2017 cheap keyboards, interesting the difference in latency rating between his setup and rting's https://www.rtings.com/keyboard/reviews/razer/ornata-chroma https://www.rtings.com/keyboard/reviews/razer/ornata-chroma
- srmarm 5y agoI guess it wouldn't work with the lab setup, but it'd be interesting to see how various laptop keyboards factor in. My one here has very short travel (similar to a apple magic keyboard) and is the ribbon cable to motherboard connection going to be quicker than USB? I'm dubious about the accuracy of their lab setup though. From the write up - "The start-of-input was measured by pressing two keys at once -- one key on the keyboard and a button that was also connected to the logic analyzer." that seems like a very week point in what is otherwise a great experiment although they do state "The median jitter was < 1ms" which surprises me.
- captainmuon 5y agoI've been thinking about building a new PC, mostly for development (if the budget allows also for a bit of gaming), and was wondering what components to pick to reduce latency and to get a satisfying feeling of "immediacy". Like when I first got an SSD and apps started instantly. Or when I got my first > GHz PC and optical mouse, and the cursor moved so smoothly it was uncanny. For input to screen latency, I think wired keyboard and mouse would be important. For "instant app opening" a recent CPU and enough RAM, and a NVME SSD. But beyond that I'm not sure. Does anybody have any recommendations or tips? Does a 140 Hz or G-Sync monitor help? Are there any pitfalls (I've heard anecdotically that some CPU power saving states can cause micro-stutter)?
- justwalt 5y agoA 144hz monitor makes a huge difference. It will cut the inherent max latency of a display frame from 16ms to 6ms. They feel amazing.
- ComputerGuru 5y agoSome days it feels like I have the last non 16:9 monitor ever made (and it’s not even 4:3, it’s just 16:10). Every year I search for a true 10-bit IPS 16:10 (or better) hi-dpi or hi-FPS (ideally both) monitor and every year I’m disappointed. My ZR30W is the oldest part of my PC (Model F keyboard notwithstanding) and has survived maybe four builds.
- opencl 5y agoThere are a couple of 10 bit IPS 4096x2560 monitors these days. They are ludicrously expensive, but they are out there.
- opencl 5y ago144Hz monitors are definitely a noticeable improvement over 60. GSync/Freesync are nice in games, not really relevant elsewhere. If you want to avoid microstutters associated with power savings you can adjust the minimum clock the CPU governor will set.
- leephillips 5y agoA related issue: this article measures the latency of a large selection of terminal emulators, with interesting results: https://lwn.net/Articles/751763/ https://lwn.net/Articles/751763/
- amomo 5y agoI recommend "battle non sense" youtube's channel for latency reviews
- FridayoLeary 5y ago>keyboards are often more powerful than entire computers from the 70s and 80s! That's interesting. Has anyone hacked a keyboard? It sounds like a very interesting project.
- errantspark 5y agoI just want to chime in and say that at with my personal computer setup I was not able to recreate these findings at all. I was getting keypress to character latencies of around 30ms in Windows gVim as measured by averaging multiple runs w/ a 240Hz camera. I don't even think I have a particularly low latency setup as I'm using an eGPU.