[SDL] Keyboard movement: Can't use two keys at once?

Rasmus Neckelmann neckelmann at gmail.com
Thu Sep 14 01:29:03 PDT 2006

On 9/14/06, DARKGuy . <dark.guy.2008 at gmail.com> wrote:
> [snip]
> but I don't see how
> SDL_KEYUP would help me in this case...

When you receive a SDL_KEYDOWN event for 'up arrow' you can set a
'Ship Moving Up' flag, and later when you receive a SDL_KEYUP event
for 'up arrow' you can clear it.

Alternatively you can use the SDL_GetKeyState() function to get a
snapshot of the entire keyboard state. Then you can have logic like:

"if up-arrow is pressed then move ship up"


Rasmus Neckelmann

More information about the SDL mailing list