Accepting more simultaneous keyboard inputs

Karl picture Karl · Jan 3, 2011 · Viewed 28.8k times · Source

Sometimes, a normal computer keyboard will only accept user's inputs up to a certain key simultaneously. I got a logitech keyboard that can accept up to 3-4 key presses at the same time. The computer does not accept any more input if you press more than 4 keys for this keyboard. And it also depends on certain areas of your keyboard as well. Some locations allow more key to be pressed (like the arrow keys), while some locations permit you to press only 1-2 keys. This also differs from keyboard to keyboard as well. Some older keyboards only accept up 1-2 keys.

This isn't problematic with usual office work, but when it comes to gaming. For instance, imagine a platform game, where you have to jump, attack, and control direction at the same time. This implies several key presses and some keyboards cannot accept such simultaneous input. However, I've tried this on several games and the amount of possible keyboard inputs seem to be also different. Therefore, we have two issues:

  1. Keyboards have different amount of simultaneous inputs.
  2. Some games can accept more keyboard inputs than other games.

At first, I thought this is hardware only problem, but why do some programs behave differently? Why some programs can accept more keyboard inputs than other programs? So how can we write our programs to accept more keyboard inputs?

Answer

James Snell picture James Snell · Feb 15, 2011

The quote from the other forum is completely incorrect...

Keyboards always use a matrix and an 8x8 arrangement on the key membrane / microswitches would cover 64 keys. Sending power down a common row and picking up which column(s) (if any) power was connected to one at a time - it just scans very quickly. The controller chip can easily determine as many keys down at one time as it wishes (including all of them) without taking any kind of performance hit (it has to poll every key anyway, up or down).

That info is then serialised by the keyboard to inform the host which events have occurred (limiting factors being the design of the chip #1 and the amount of traffic it wants to put on the bus #2). They're converted into the appropriate OS events by the drivers (limiting factor #3). Those events are then handled by applications, which in turn may have their own limits on the number of keys they track (#4).

There's a lot going on, but they haven't used 1 wire per key + ground since about the 60's. And if you don't think the matrix could scan fast enough - look at any lcd/led screen, that's the same matrix happening, just in reverse.