Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

fury3

WM_KEYDOWN stalls!

This topic is 6914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!