Keyboard nerdery

From Helpful
Jump to navigation Jump to search

How most systems deal with varying keyboards (an introduction to the wild world that is keyboard input)

"How do I type the euro sign on my keyboard"

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.


If you're in the EU, your keyboard probably has a € as a third symbol on the 5, the E, or the 4(verify).

How do you even use that?

It turns out to be a much better question that you'ld think, in that this is far from obvious.


tl;dr:

  • if you set the keyboard to a language that support is, there will be a key combo
it might be CtrlAlt5
it might be Option2 or OptionShift2
it might be something else


Key rollover

When you have a lot of buttons, you can give each one their own pair of wires and input, but it is much more economical to use fewer wires.


This implies there is a limit of buttons that you can press at the same time before it becomes ambiguous.

When it does, a hardware implementation has the option to

  • ghost - keys are registered unrelated to the ones you pressed, or
  • block - not emitting some of the keys you pressed

Most controllers, when they run into this limit, will block rather than ghost -- it's the safer option that also leads to fewer angry helpdesk calls.


As a result, key rollover refers to the number of keys that can be registered simultaneously without either ghosting or blocking.

Not the best case or average, the worst case - the thing you can guarantee.


Limits happen within clusters.

  • Take the cheap keyboard I'm typing this on.
I can press all of ASDFGHJKL at once - that's 9 right there.
Yet if I hold down Q and A, I can't press E. This keyboard is in fact 2-key rollover (2KRO).
  • The same keyboard, within QWEASD
most combinations of 3 are fine
many combinations of 4 are fine
a few of 5 are fine
In fact, all problems seem to happen when pressing Q and E.
  • At the same time, I have zero conflicts within WASDFGR (and I can add either of Q or E, but not both).
Or, in fact, within WASDFGR, Shift, Control, Space, Tab - that's 11 keys.
In fact I can get a rather specific combination of 13 keys (probably a few more, but it's very uncomfortable on the hands).


I'm assuming this is not uncommon in 2KRO keyboards, because game designers tend to put a lot of actions on those ten keys, and sorta-exclusive things on Q and E. Due to the way gamers land on WASD and use one finger to do the Q and E, you may never even have noticed this even playing on cheap 2KRO keyboards.

But - another cheap keyboard I have, also 2KRO, has a lot more conflicts within that same sorta-gaming set. Still mostly fine in most games, but enough to bother me.

This is one reason that 2KRO is a crapshoot for gaming (sometimes perfectly fine, sometimes bad), and 6KRO is the "basically never have to worry about it" choice. (well, NKRO is, where every key is scanned independently, but 6 is practically almost impossible to find problems on)


Why limits?

The difference between the rollover number, and the maximum, and the fact that specific keys will and won't work together, often comes mainly from the way it's wired, and to a lesser degree from how it communicates.


Wiring

Sure, you could wire all ~100ish keys separately, but that's so much wire, and difficult to route.

It's not even that wire costs much more. It's that routing that many wires around each other is somewhere between 'really messy' and 'impossible', depending on further constraints.


Instead, you can wire it in a way that is conceptually very similar to a switch matrix -- and probably best introduced that way.

This shares wires (look at multiplexing). Pressing any one is unambiguous, whereas specific combinations may be ambiguous or not.


When ambiguous, the controller has a choice - it can send out extra keypresses for things you didn't press, or it can say 'this is messy, I will send out nothing', which is clearly the safer choice. (again, ghosting and blocking)

Because of some practical details, it turns out that 2KRO is fairly simple to do, while more than that gets more involved.


Communication

The way it's communicated can also be a limitation.

Yet there are some silly (but very persistent) myths around this.


For example, USB has a simplified variant of keyboard protocol, with fixed size packets, with one byte reserved for modifier keys, and space for six scancodes.

This protocol is used during the text-mode part of PC boot, when the BIOS is still in control because there is no OS in the picture yet.

The BIOS's USB stack can be a lot simpler when it only has to deal with this simple variant.


This has led to the myth that USB is only ever 6KRO.

Yes, this simplified format is 6KRO, but only during boot.

And yes, many cheap keyboards implement only this protocol, because it's enough.

More so if its key wiring is not much better than 6KRO anyway.


But a full USB implementation includes all of USB HID spec, which can basically already work around that problem, e.g.

by switching to a device-specific driver (it would only be 6KRO during early boot, when it really doesn't matter).
by reporting as multiple completely standard 6KRO keyboards

Some NKRO keyboards do the latter.

But many seem to prefer the driver way, more so when there's also colorful blinky LEDs to control(verify).


An even sillier myth is that because PS2 didn't have this problem (it sends a packet for each event), using one of those USB-to-PS2 adapters will make it it NKRO.

This makes no sense whatsoever, for multiple reasons. But the main one is that if your OS doesn't know how to talk to your NKRO keyboard, then neither will a generic adapter. And what it talks after that happens is irrelevant.



So how much do you need?

2-key rollover might be good enough for typing, because you tend to hit only one or two keys at a time.


Gamers will often be holding down four or five keys, so 2-key rollover isn't great,

sure it may work - I never noticed either of my 2KRO keyboard were that before.
but 2 is the only guarantee you have
The better one has no conflicts within the most typical gaming keys - involving more keys than I have fingers.
The worse one is still mostly fine within the keys you would most typically hold together in games.


But that difference also illustrates that you'll never know exactly which combinations of keys aren't going to work.

So if you want a guarantee, you look for designs that guarantee it.

Most gamers will be perfectly fine fine with 6KRO, because the specific combinations of 7 keys you can't hit are even harder to hit (certainly with one hand), and even easier to avoid by design.

NKRO then is overkill - but also the simplest way to never have to think about it again.


See also:

Keyboard response time

PS/2 protocol

Keycodes