Sign in to follow this  

sdl key state question

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

In my current demo you have to press the 'p' key to pause the game. The only problem is the game resumes after you release the 'p' key. Is there an easy way to make it so that when I push the 'p' key the game will pause until the 'p' key is pushed again??? Thanks for any tips or tricks on the matter.

Share this post


Link to post
Share on other sites
It's because you get an event when you press the key and one when you release it. Since you don't check what type of event it is (only if it's related to the 'p' key), you toggle the pause when the key is pressed and when it's released. Toggling the pause state only when the event is a SDL_KEYDOWN (and not when it's SDL_KEYUP) should do the trick.

FWIW, I answered your question here already. [grin]

Share this post


Link to post
Share on other sites

This topic is 4108 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.

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