Sign in to follow this  
Icebone1000

Win32 - GetKeyboardState vs GetAsyncKeyState

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this