user3312507
user3312507

Reputation: 29

How to check if a key has been released using keystates SDL

How can I see if a key is released via keystates in sdl.

const Uint8 *keystate = SDL_GetKeyboardState(NULL);

if (keystate[SDL_SCANCODE_UP])
{
    renderer();
}

Upvotes: 2

Views: 735

Answers (1)

ysalmi
ysalmi

Reputation: 539

You'll need to store and update every frame a list of states for the keys you are interested. A key is released if it was pressed in the previous frame and it is not pressed in this frame.

Upvotes: 1

Related Questions