SDL_GetKeyState question

I am trying to retrieve the state of the keyboard so that I can read
multiple keys at a time.

My code is something like this…

Uint8 * keys;
keys = SDL_GetKeyState(NULL);

while (keys[SDLK_ESCAPE] != SDL_PRESSED) {
//do stuff;
keys = SDL_GetKeyState(NULL);
}

the program never ends even when I hit the escape key.
Why is this?

Am I forgeting to initializee some event or keyboard thing before I start
this? All I initialize is the video currently.

I am using SDL 1.0.8

Dave Leimbach
(Leimy)

My code is something like this…

Try this:

Uint8 * keys;
keys = SDL_GetKeyState(NULL);

while (keys[SDLK_ESCAPE] != SDL_PRESSED) {
//do stuff;
SDL_PumpEvents();
keys = SDL_GetKeyState(NULL);
}

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

So I need to call PumpEvents… Hmmm not in the API docs…
Oh well, thanks…

DaveOn Mon, 24 Apr 2000, Sam Lantinga wrote:

My code is something like this…

Try this:

Uint8 * keys;
keys = SDL_GetKeyState(NULL);

while (keys[SDLK_ESCAPE] != SDL_PRESSED) {
//do stuff;
SDL_PumpEvents();
keys = SDL_GetKeyState(NULL);
}

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software