this post was submitted on 22 Feb 2026
28 points (91.2% liked)

Programming

25718 readers
369 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
top 17 comments
sorted by: hot top controversial new old
[–] ulterno@programming.dev 1 points 5 hours ago* (last edited 5 hours ago)

I bought a "gaming" mechanical keyboard from ANT eSports, which boasted 6KRO (or some number like this) Anti-Ghosting and RGB backlight written in some parts of the package, while rainbow LED was written in others.

Result:

  • I learnt that "rainbow" is not RGB
  • It was not anti-ghosting. In fact it failed some common key combinations that even a $2 Dell keyboard did pretty well.
  • its switches started going bad at day 3, which I only realised after opening the switch and realising that the bent contact material of the Kailh Red switches were not springy and were just getting stuck in position.
    • I guess this one is my bad for asking them to just hand me the display model

As far as latency goes, there is a point that I read somewhere that it's better to connect User Input devices to USB 2 slots, which are on a separate hub from the USB 3 slots that you might have connected storage or networking devices to.


Most of my gaming related problems have come up related to nKRO (the absence of it). Be it space games like X4 and Elite: Dangerous or Hollow Knight ^[this one, I actually paused mid-game when I realised that the ghosted keys were making the play un-fun, so now I will either afford to buy/make a good nKRO keyboard or not play it and maybe not end up buying Silksong 😒].

I am usually too slow to notice latency in gaming cases. But I do in case of music, making me unable to use a keyboard on a computer as a musical keyboard (making music in realtime). Though the context was a heavily laggy game with a musical minigame, so it might be different when using proper musical software. I still expect it to make a big difference though.


keyboards use a matrix that has to be scanned instead of having a wire per-key because it saves a few bucks

Hehe, this was a fun statement. I was actually looking into making a keyboard for myself and while looking for available microcontrollers I could use, I found out that the difference between not using a scanning matrix (1 wire per key) and using one wa not being able to even make a 75% vs having enough address space for a 105 + 12 (extra fn keys F13 to F24 and more macro keys) layout.

I would have had to go with a PLCs or Ultrascale FPGAs with unnecessarily high processing power, because components are usually easily available for less I/O with higher throughput instead of greater parallel I/O.

On the other hand, by my calculation it was pretty easy to match the 1kHz overall polling rate using the polling rate available on the I/O pins available on a Raspberry Pi (or was it an Arduino I calculated it for? I forget), so key -> controller software latency shouldn't be a real problem.

[–] matsdis@piefed.social 9 points 1 day ago (1 children)

I found it interesting that key travel time was considered, often it isn't.

A similarly interesting article: Measure and reduce keyboard input latency with QMK on the Kinesis Advantage (2021) (Basically, took an existing keyboard and replaced the controller.)

[–] Ephera@lemmy.ml 4 points 1 day ago (1 children)

Yeah, so many people swear by mechanical keyboards with a huge amount of key travel, and I never see it discussed that the key travel itself is problematic.

[–] Glitchvid@lemmy.world 3 points 1 day ago* (last edited 1 day ago)

This has been an extolled benefit of the new Hall/TMR design keyboard/switches.

Because they deal with a continuous activation level, you can define in software when the "press down" signal gets fired in the key travel, including immediately stopping the press once it stops traveling down, and resuming it in the reverse; effectively eliminating pre-travel.

These boards apparently started getting banned in comp play even, from what I've heard. Caveat emptor, I'm not into the comp gaming scene.

[–] FizzyOrange@programming.dev 1 points 18 hours ago

The connection column indicates the connection used. USB FS stands for the usb full speed protocol, which allows up to 1000Hz polling, a feature commonly advertised by high-end keyboards. USB is the usb low speed protocol, which is the protocol most keyboards use.

USB Low Speed allows 1kHz polling too. I don't think you gain anything at all from High Speed. Keyboards probably only use it incidentally because the chip they are using happens to support it anyway.

[–] tal@lemmy.today 4 points 1 day ago* (last edited 1 day ago)

That's...actually a substantial amount more latency than I'd expected. Not exactly the same thing, but for perspective, while I haven't played multiplayer competitive FPSes for many years, back when I did, the limit of what I could really "feel" when it came to network latency was around 10 milliseconds. The latency the keyboards are adding, if it's as high as measured, is a really substantial amount of delay to be adding if you're talking video games.

considers

Note that depending upon the keyswitch mechanism, the controller does need to debounce the thing to avoid duplicate keypresses. I've used a keyboard before with a controller that didn't adequately debounce, and it was extremely obnoxious


occasionally would get duplicate keypresses, and I had to filter it out at the level of my computer.

However, if you look at gamepad button latency, they also need to worry about bounce, and their latency is much lower:

https://gamepadla.com/

You can get gamepads with sub-2-millisecond latency on USB.

EDIT: Note that one thing that I learned from following !ergomechkeyboards@lemmy.world is that there are some semi-standardized open-source firmwares for (fancy, expensive) microcontroller-based keyboards; I believe that QMK is popular. I don't know how the latency on those microcontroller-based keyboards compare, but assuming that there aren't any fundamental constraints imposed by the other hardware on the keyboard, it might be possible to shave some time off of that by tweaking the firmware.

I believe that at least some keyswitch mechanisms become more prone to bouncing over time, but if so, it might be possible for a microcontroller to detect bounces and tune the wait time to the mechanism on a given keyboard to adapt to mechanism wear.

[–] Kissaki@programming.dev 1 points 21 hours ago

When I was researching keyboards recently, I stumbled over a pro gamer (I believe) YouTuber who was quite vocal about pretty much all gear marketed as "gaming gear" is overpriced marketing bullshit. Apparently, they tested dozens of keyboards, mice, and headsets over the years. It certainly matched my impression of reading tests about products previously.

"Gamer" chairs are racecar chairs meant to keep you from sliding sideways, not being fit for long sitting sessions on a PC. Prefer a good or decent office chair. "Gamer" headsets are worse and more expensive than other headsets. Keyboards and mice are mostly marketing. etc.

Regarding input, they made a point about physical human limitations and state like sleep and caffeine intake having much more of an effect than the hardware you use.

2022 update

So this article is quite old. There are keyboard switches now that activate as soon as you activate the key, and that can recognize lift and press without passing a trigger point. If you want that kind of edge, those are the top performers right now. I'd be more interested in the technology and maybe playful capabilities than the performance they add.

I'm always way too thorough when researching products before buying…

[–] naeap@sopuli.xyz 1 points 21 hours ago* (last edited 20 hours ago)

Can someone enlighten me, how to debounce without causing latency?

In the article, he only says "Now, how to debounce without adding latency has become common knowledge", and I have absolutely no clue how that should work

Edit: seems they just wait for the signal edge and ignore any signal "jumping" for some time afterwards
Probably works ok/good with keyboards, but not with every application of debouncing

[–] tal@lemmy.today 2 points 1 day ago* (last edited 1 day ago) (1 children)

Another thing to note about gaming keyboards is that they often advertise "n-key rollover" (the ability to have n simulataneous keys pressed at once β€” for many key combinations, typical keyboards will often only let you press two keys at once, excluding modifier keys). Although not generally tested here, I tried a "Razer DeathStalker Expert Gaming Keyboard" that advertises "Anti-ghosting capability for up to 10 simultaneous key presses". The Razer gaming keyboard did not have this capability in a useful manner and many combinations of three keys didn't work. Their advertising claim could, I suppose, technically true in that 3 in some cases could be "up to 10", but like gaming keyboards claiming to have lower latency due to 1000 Hz polling, the claim is highly misleading at best.

That being said, the real issue was keyboards that used matrix encoders, where all keys were represented in a matrix, addressed by one line going high on the X axis and one line going high on the Y axis. I understand that this is cheaper, and expect that it's probably because this requires running fewer traces from the keys to the controller than doing one for each. It looks Something like:

- X1 X2 X3
Y1 "Q" "W" "E"
Y2 "R" "T" "Y"
Y3 "U" "I" "O"

That's just a 3x3 matrix, as an example. So if I press "Q" on my keyboard, the X1 and Y1 line will go high. If I keep it pressed and then additionally press the "W" key, the Y1 line, which is already high, will stay high. The X2 line will then also go high. The controller can detect the keypress, since a new line has gone high.

If I keep both keys pressed and then additionally press the "R" key, then the X1 line is already high due to the "Q" key being down, and will stay high. The "Y2" line will go high. The controller can detect the keypress.

However, if I then press the "T" key, it can't be detected. Pressing it would normally send the X2 line and Y2 line high, but both are already high due to existing keys being pressed.

In practice, keyboard manufacturers try to lay out their matrix to try to minimize these collisions, but there's only so much they can do with a matrix encoder. They'll also normally run independent lines for modifier keys.

A controller using a matrix encoding can always detect at least two keys being simultaneously pressed, but may not be able to detect a third.

Matrix encoders aren't really an issue when typing, but some games do require you to press more than two non-modifier keys at once. For example, it's common to use the "WASD" keys for movement, and moving diagonal requires holding two of those. if someone is playing a game that requires pressing another key or two at once, those might collide.

As I recall, USB sends the full state of the keyboard, not events specific to a button when a button is pressed. There are protocol-level restrictions on the number of "pressed keys" that can be pushed. That means that USB keyboards don't support n-key rollover, and are why you'll see some companies selling gaming keyboards with a PS/2 option


because that protocol does send state on a per-button basis. (It's also why, for those of us that have used PS/2 keyboards and have experienced this, it's possible to get a key on a PS/2 keyboard "stuck" down until it's pressed again if the OS, for whatever reason, misses a key-up event.) USB gaming keyboards probably (hopefully) won't actually advertise n-key rollover. But they can avoid using a matrix encoder, and in general, one really doesn't need n-key rollover for playing games


just the ability to detect up to the USB limit. We only have ten fingers, and I don't think that there are any games that require even something like six keys to be down at once.

Obviously, in the case the author hit with the Razer keyboard, it wasn't able to do that. I'm not sure what they're doing (unless they're simply completely fabricating their feature claim, which I assume that they wouldn't). They might be using a larger matrix and sparsely-populating it, though I'm guessing there.

[–] HakFoo 4 points 1 day ago

The "default" mode for a USB keyboard allows submitting 6 keys + modifiers. Some boards define nontraditional input descriptors that allow more, but that mode is not guaranteed to work in places like the BIOS menu or naive KVM switches.

To avoid phantom keypresses when you hit three keys in a "square" on the matrix, a diode can be placed in series with each switch so current can't go through an "indirect" route.

I learned programming on Apple II and the fast keyboard reaction felt really good. I hate it when keys lag.

[–] MonkderVierte@lemmy.zip 2 points 1 day ago

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.

Hah, slim keyboars for the win.

[–] MonkderVierte@lemmy.zip 1 points 1 day ago* (last edited 5 hours ago) (2 children)

~~They notice 50 ms vs. 200 ms? Back then in Windows 7, there was a registry hack to chabnge the autohide animation duration of the taskbar. 400 ms was default, 300 ms fast and 200 ms was snappy. This was a lession to me, that interaction/interface stuff plays in the 100 ms at most.~~

Edit: guess it's different in input vs. animation.

[–] HaraldvonBlauzahn@feddit.org 4 points 1 day ago* (last edited 23 hours ago) (1 children)

50 ms is clearly noticeable. Dan Luu mentions 2ms in the original post.

Try in a terminal

read a; sleep 0.02; echo $a

and vary the number.

Actually, the time resolution for visual sensations is at least 5ms and for sound it is even smaller - a drummer in s band needs to practice a lot to get the right beat.

[–] MonkderVierte@lemmy.zip -1 points 1 day ago

Terminal echo is not a good measure, far too slow. Make it a C program.

[–] tal@lemmy.today 3 points 1 day ago

You can definitely feel 100 ms in input response time. That's about what an analog modem's latency would be. I can tell you, that's very much noticeable on a telnet or ssh connection when you're typing (though to be fair, what matters there is really round-trip time, so one should probably double that).

On that note, if someone hasn't run into it, mosh uses UDP and adaptive local echo to shave down network latency for terminal connections, and might be worth looking into if you often do remote work in a terminal over a WAN. It uses ssh to bootstrap auth (if you're concerned about using less-widely-used thing what does network authentication, which I remember I was). I find that it makes things more pleasant, and also like some of its other features, like auto-reconnecting after an arbitrary length of time. One can just close a laptop and then reopen it a week later and the terminals function. Tmux and GNU screen can also do something similar


and in fact, I think that mosh and tmux are good packages to pair with each other


but they don't do quite the same thing, as they require (a) manual re-establishment of connection and are (b) aimed at letting one reconnect from different clients. It also displays a notice in the terminal if there's temporary network unavailability until it's re-established communication, so the user isn't simply staring at his screen wondering whether the software on the remote machine is being unresponsive or whether it's a network issue.

[–] Kissaki@programming.dev 0 points 21 hours ago

This doesn't seem programming-related. Am I missing something?