Advertisement

WM_KEYDOWN stalls!

Started by May 18, 2000 06:18 PM
5 comments, last by fury3 24 years, 7 months ago
Hi I''m writing a game where the user gives commands via the keyboard. I do this by checking for the message ''WM_KEYDOWN'' in my Wnd_Proc function. This works fine, as long as only a few keys are being held down. If more than 3 keys are held at the same time, no further WM_KEYDOWN messages are passed to my program until I have let go of one of the other keys. HELP! Is it possible to retrieve further WM_KEYDOWN messages? Is there another way to check for keys that have been pressed? Thanx in Advance
The best way is to use Direct Input. You can read as many keys as the keyboard feels like sending. Most keyboards, for instance, will not send 100 keys being pressed at the same time, but all will send more than 3 I would think.
Advertisement
Have you tried something like:

#define KEY_DOWN( vk_code ) ( GetASyncKey( vk_code ) & 0x800 1 : 0 )
Just correcting a few errors with baskuenen's macro. You want to test the most significant bit so the function will need to test against 0x8000 not 0x800. Also the function is called GetAsyncKeyState(), and you missed out the "?" mark. Try this:

#define KEY_DOWN( vk_code ) ((GetAsyncKeyState( vk_code ) & 0x8000) ? 1 : 0 )

-- Jon Hobson --

Edited by - JonHobson on May 18, 2000 8:07:01 PM
---------- JonHobson ----------

I recently had that problem with 1-key presses because I forgot the break; at the end of the case WM_KEYDOWN:

Maybe you forgot a break somewhere?? Just a small thought.
Even the functions don''t seem to notice that a key has been pressed if I hold a lot of them down at once... must be the keyboard methinks.

Thanx alot anyway!

Advertisement
quote: Original post by Buster

Most keyboards, for instance, will not send 100 keys being pressed at the same time, but all will send more than 3 I would think.


In fact, it's more complex than that. I don't know exactly how it works, but some keys don't like to be pressed at the same time whereas others don't care.

It's a kind of mystery.

Try : LEFT_ARROW + W + X + C
It doesn't work.

Now try : LEFT_ARROW + A + S + D
It works, although more keys are pressed ?!

Oups! My keyboard is azerty, so here are the examples for qwerty keyboard users :
LEFT_ARROW + Z + X + C
and LEFT_ARROW + Q + S + D

If someone knows how it really works...



Edited by - Prosper/LOADED on May 19, 2000 10:49:29 AM

This topic is closed to new replies.

Advertisement