SDL halt/stop a keypress DOWN

Is there any code which you can stop/halt the keypress?

like

Code:
if( event.type == SDL_KEYDOWN ) {
switch( event.key.keysym.sym )
{
case SDLK_LEFT: break;
case SDLK_RIGHT: break;
case SDLK_SPACE: //do something break;
default: break;
}
}

and a timer for example thats halt it.

Code:

if(timer>=600) {
SDLK_SPACE =NULL;
}

[/code]

Ostburk wrote:

Is there any code which you can stop/halt the keypress?

like

Code:
if( event.type == SDL_KEYDOWN ) {
switch( event.key.keysym.sym )
{
case SDLK_LEFT: break;
case SDLK_RIGHT: break;
case SDLK_SPACE: /do something/ break;
default: break;
}
}

and a timer for example thats stops the keypress form being down to up even if you hold SPACE down on your tboard, you need to press it again.

Code:

if(timer>=600) {
SDLK_SPACE =NULL;
}

Unless you enable auto repeat the keydown and keyup events should only fire once, so the user would need to press the key twice if they wanted the event fired off twice.

Rather than using a timer, I take a snapshot of the SDL_GetTicks() for the last press and then say:

Code:

case SDLK_SPACE:
if ((SDL_GetTicks() - lastpress) > 600) {
// ???
// Profit!
}

Is this what you were referring to? Or did I not understand your question correctly? (happens more than it should)

  • Micah