0

Hello, everyone!

I'm using the Win32 API PeekMessage function to retrieve key stroke events. I have a problem: suppose that someone holds the A button. PeekMessage will return messages for the A press event. Now, while A is pressed, someone holds B. PeekMessage will return only the B press event message.

Do you know a way to retrieve A messages, even if B is holded by the player?

Thank you!

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by Taurusk
0

Well you could keep an array of boolean values representing the keys on keyboard. Whenever you receive a WM_KEYDOWN or WM_KEYUP message you flag the corresponding key (wParam) as either true (pressed) or false (not pressed).

This way you should always be able to keep track of which keys are pressed, and which ones that aren't.

I hope this helps!
Emil Olofsson

0

I strongly suggest using DirectInput for this sort of keyboard handling, it vastly simplifies the handling of multiple keypresses and can be easily implemented using the message processing model you have mentioned below.
There are many examples on Microsoft's website on how to use DirectInput, in particular I recommend downloading the DirectX 9 SDK and checking out the samples included.

Hello, everyone!

I'm using the Win32 API PeekMessage function to retrieve key stroke events. I have a problem: suppose that someone holds the A button. PeekMessage will return messages for the A press event. Now, while A is pressed, someone holds B. PeekMessage will return only the B press event message.

Do you know a way to retrieve A messages, even if B is holded by the player?

Thank you!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.