Jump to content
  • Advertisement
Sign in to follow this  
ferr

GetKeyState too Sticky

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

I'm using GetKeyState for input in a project I'm working on and I'm having some trouble with it. For example: 1) User presses E to enter Weapon Shop. 2) User now has the option to press E to select a Weapon, but as soon as the user enters the shop a weapon is selected, it would seem that the previous pressing of E has been passed over. I have some sleep() after getting key states, but that doesn't seem to change much. Any ideas? Is there a way to "remove" or release the current key state before proceeding to something else? Changing the user's input option (i.e. pressing X instead of E on the second part) isn't really an option I want to look into.

Share this post


Link to post
Share on other sites
Advertisement
Just save the state of the key each frame and only execute an action if the state changes from KeyUp to KeyDown, that way you only activate the action once when the key is pushed down.

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!