15
\$\begingroup\$

I am working on a 2d side-scrolling pc game that uses SFML game library. The problem that I am not able to solve is that in many keyboards combination of three or more keys (like w + d + k) is not working. Is there any way to solve this issue?

\$\endgroup\$
  • 1
    \$\begingroup\$ I've never had a keyboard where W+D+K would result in a ghosting issue. Are you sure what you're seeing is ghosting and not a limited number of simultaneous inputs on your keyboard? \$\endgroup\$ – Logarr Sep 30 '15 at 14:38
  • \$\begingroup\$ @Logarr "Ghosting" is the problem that some keyboard keys don't work when multiple keys are pressed simultaneously. The key presses that don't show up on the computer or seem to have disappeared are said to have been "ghosted". \$\endgroup\$ – Cees Timmerman Nov 24 '15 at 11:12
  • \$\begingroup\$ @CeesTimmerman - I know exactly what ghosting is. What I'm saying is that since W+D+K do not form an intersection, I have never had a keyboard that was designed in a way that had that combination ghost. \$\endgroup\$ – Logarr Nov 24 '15 at 15:03
  • \$\begingroup\$ @Logarr Then the limit would be in OP's software, not the keyboard or its driver. Also, not all keyboards are the same. \$\endgroup\$ – Cees Timmerman Nov 24 '15 at 15:46
28
\$\begingroup\$

You can't. At least, not as a game developer.

As a gamer, you can purchase more expensive keyboards with "anti-ghosting" features, but otherwise the limitation is part of the hardware itself, so there's nothing you can do in software to solve it.

Check out this demo page to see how keyboard ghosting works, plus a demo: http://www.microsoft.com/appliedsciences/antighostingexplained.mspx

So your best bets are:

  • Don't use a control scheme that requires too many simultaneous key presses
  • Use game pads if they are available
  • Let the player remap the keys so they can find a non-ghosting set of keys for their hardware
  • If you must, stick to the left side of the keyboard (around WASD) because keyboards tend to avoid ghosting around here

Historically, many PC games used modifier keys (Ctrl, Alt, Shift) as part of their controls because these keys were wired to handle being pressed together with other keys, to avoid ghosting. This practice sort of fell out of favour during the 90s because the modifier keys were being used more and more by the OS, which would interfere with the game.

Later, certain genres of games had their controls coalesce around key clusters, most notably the FPS genre around WASD + mouse, but another example would be Japanese indie games around ZXC + arrows. In a self-fulfilling manner, since most games used these clusters, keyboard manufacturers also made sure that ghosting was minimised around this area, so if you stick to the same controls that other popular games use, you will also avoid ghosting.

Looking at your example, W and D are fine but K is not; are you by any chance using K as a directional control? If so, consider using the arrow keys instead.

\$\endgroup\$
  • 1
    \$\begingroup\$ Your answer starts with "You can't", but then you give good advice on exactly how to avoid it. I think the right answer here is "pick control keys that don't have a ghosting issue on most keyboards". Good info here. \$\endgroup\$ – JPhi1618 Sep 30 '15 at 19:05
  • \$\begingroup\$ @JPhi1618 i think there's a difference between "here's how to avoid ghosting" and "here's how to deal with the fact that most keyboards have keyboards that ghost" \$\endgroup\$ – undergroundmonorail Sep 30 '15 at 20:54
3
\$\begingroup\$

Buy a better keyboard.

Ghosting is caused by the hardware itself. Even many gaming keyboards will still have this problem; they only invest in fixing the problem for "common" keys like WASD (but not 'K' for instance).

http://www.microsoft.com/appliedsciences/antighostingexplained.mspx

\$\endgroup\$
  • 6
    \$\begingroup\$ ...and tell all your customers to also buy better keyboards? This doesn't sound like the most user-friendly solution. \$\endgroup\$ – Philipp Sep 30 '15 at 10:02
  • \$\begingroup\$ Life is hard. Force your customers to buy better hardware or don't design games that are intrinsically broken on commodity keyboards. This ain't exactly rocket science. :) \$\endgroup\$ – Sean Middleditch Sep 30 '15 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.