Jump to content
  • Advertisement
Sign in to follow this  
Icebone1000

Win32 - GetKeyboardState vs GetAsyncKeyState

This topic is 3145 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

Whats the best way to handle keyboard input for games? Getting the state of all the keys every frame, and so checking witch ones you want to see if it is pressed, or, get the state of all the keys you want to check one by one ? I cant see much difference..in both you will have to do a specific key by key check, the get Keyboardstate seems less efficient since you never will need all the keys checked, but is just one function call... Maybe the best way is really on the performance of each function?? What do you know about it?

Share this post


Link to post
Share on other sites
Advertisement
If you're keyboard code is soaking all your CPU time then you're game is too small to be worth optimising or you are doing something terribly wrong. Don't waste your time optimising something unless you have proof it is a bottleneck.

Personally, I prefer having a high level event system, I only care when keys are pressed or released, not about the current state of the keyboard.

Share this post


Link to post
Share on other sites
Its not a question about optimization...I just have 2 almost the same option, I have to choose one, if theres any performance difference, why would I use the worse one?

Share this post


Link to post
Share on other sites
You should probably just handle the WM_KEYUP and WM_KEYDOWN messages, that way you don't need to do any work unless a key has been pressed.

Share this post


Link to post
Share on other sites
Well, if he needs the current state, not events, then all he would do with key-up/down messages is maintain his own state array, which is a silly redundance. It might even be slower. :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!