1
votes

I've been trying to track down a bug in my program. I noticed that whenever I am holding down the up and left arrow keys and press the spacebar, a WM_KEYDOWN message with a WPARAM of VK_SPACE is never received or processed by my WndProc.

I was a bit curious, so I opened up Spy++ and started viewing the messages sent to my window. I noticed that when I am holding down the left and up arrow keys and press another key, say A, the WM_KEYDOWN (as well as a WM_CHAR) message is sent to my window.

But if I'm holding down the up and left arrow keys and press the spacebar, a WM_KEYDOWN message for the spacebar hit is not sent to my window.

What is the reason for this? Could anyone confirm this behavior?

1

1 Answers

2
votes

This happens because your keyboard is doing what is called ghosting. This is normal for the majority of keyboards used by people today. It's wired up so that it's a lot cheaper to produce, and as a result, things like this happen consistently.

Basically when three keys in the same row/column are pressed at once, they cannot all be uniquely identified, causing at least one not to go through. The only thing you can do is buy an anti-ghosting keyboard, or redesign your controls to avoid conflicts.

On a personal level, I found out about this a day or two before I presented my game and ended up having to make the controls something like P1: SZXC and space and P2: /789 and +. It really is a good thing to know beforehand.