SDL_GetModState question, sam, anyone? please?

I have been trying to detect whether or not a person is holding down the
shift and escape key at the same time, I figured that SDL_GetModState
would be the function to detect that SDLK_LSHIFT is being held down.
However, I have been unable to successfully figure out how to use
SDL_GetModState. I really need someone to explain how this function
works :expressionless: None of the examples that I found on the SDL page, or in the
SDL package use this function. Is it obsolote or deprecated now?

Thanks for your time,
DrEvil
@EvilTypeGuy

P.S. Two Examples of my pitiful attempt to figure out SDL_GetModState
follow:

The 1st one:
Uint8 *keys;
keys = SDL_GetKeyState(NULL);
if(SDL_GetModState() == KMOD_LSHIFT) {
if(keys[SDLK_ESCAPE] == SDL_PRESSED) {
printf(“Quitting…\n”);
}
}

The 2nd one:
Uint8 *keys;
keys = SDL_GetKeyState(NULL);
if ((SDL_GetModState() == SDLK_LSHIFT) && (keys[SDLK_ESCAPE] ==
SDL_PRESSED) ) {
printf(“Quitting…\n”);
}

Try this one (untested)

if ( (SDL_GetModState() & KMOD_SHIFT) && (keys[SDLK_ESCAPE] == SDL_PRESSED) )

Make sure that you are calling SDL_PumpEvents() to run the OS event loop.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec