Monday, August 8, 2011

Keyboards - The Three Key Problem


When choosing default keys for your game, you might be inclined to use the spacebar in combination with the arrow keys, but there's a big problem with using those particular keys. A lot of keyboards don't allow you to press certain combinations of more than two keys at the same time. I had forgotten about this and just recently, while working on my bullet hell shooter, I started out using the spacebar and arrow keys to get my player shooting and moving. I quickly noticed that I couldn't move my player to the upper-left while pressing the spacebar. This is a pretty common problem.

So first of all, why does this happen? Shouldn't we be able to use the spacebar with two other arrow keys? Seems crazy, right? There's a simple explanation for this. This isn't a problem with the programming language or API you're using. The problem is actually the keyboard itself, and it stems from a design decision so that manufacturers can cut costs making Keyboards. Shawn Hargreaves has a good explanation, so no need for me to go into detail here.

So how do we fix it? There are better keyboards available that are tailored to gamers, but obviously you can't expect everyone who plays your game to go buy one. :) The answer is to simply use different default keys, while providing a way for the user to configure those keys. Looking at other shoot-em-ups, I've found that default keys are indeed not the spacebar and arrow keys. The Touhou series is a good example of this. The current Touhou game, Touhou 13, uses left-shift, z, x, c, and arrow keys, and doesn't use the spacebar at all. Avoiding the keyboard entirely and only supporting a gamepad is definitely not a good idea. I still have yet to hook my gamepad up to my PC, and I'm guessing there's a lot of gamers in the same boat.

2 comments:

  1. Don't forget that not all keyboards have the same layout. I wrote a game that used the numeric keypad, most laptops don't have them as proper keys, also other key layouts exist other than QWERTY.

    ReplyDelete
  2. Update: I recently bought a mechanical keyboard. The Razor BlackWidow keyboard supports pressing 10 keys at once. Not that I'd ever need to do that, but it sure solves this problem. I will never be that amazing at StarCraft. =D

    ReplyDelete