   SDL lazyfoo keypresses help
  could someone point out to me why this is not displaying the text when a key is pressed?//If there's an event to handle if( SDL_PollEvent( &event ) ) { //If a key was pressed if( event.type == SDL_KEYDOWN ) {//Set the proper message surface switch( event.key.keysym.sym ) { case SDLK_UP: messageKeys = upMessage; break; case SDLK_DOWN: messageKeys = downMessage; break; case SDLK_LEFT: messageKeys = leftMessage; break; case SDLK_RIGHT: messageKeys = rightMessage; break; } } else if( event.type == SDL_QUIT ) { quit = true; } }//If a message needs to be displayed if( messageKeys != NULL ) { //Apply the images to the screen apply_surface( ( SCREEN_WIDTH - messageKeys->w ) / 2, ( SCREEN_HEIGHT - messageKeys->h ) / 2, messageKeys, screen ); //Null the surface pointer messageKeys = NULL; } 
  Your code executes many times a second, usually at least 60. This means that an instantaneous keypress message may not be visible to the eye, it is displayed for such a short time.The following code will keep displaying the message until you release a key:// use "while", not "if" to handle events// This way you handle multiple events in a timely manner.while( SDL_PollEvent( &event ) ) { if( event.type == SDL_KEYDOWN ){ switch( event.key.keysym.sym ){ case SDLK_UP: messageKeys = upMessage; break; case SDLK_DOWN: messageKeys = downMessage; break; case SDLK_LEFT: messageKeys = leftMessage; break; case SDLK_RIGHT: messageKeys = rightMessage; break; } } else if(event.type == SDL_KEYUP){messageKeys = NULL;}else if( event.type == SDL_QUIT ){quit = true;} }if( messageKeys ){ apply_surface( ( SCREEN_WIDTH - messageKeys->w ) / 2, ( SCREEN_HEIGHT - messageKeys->h ) / 2, messageKeys, screen );};  now that you say that it does make sense, but for some reason its still not working...but this does:messageKeys=upMessage;if( messageKeys ){ apply_surface( ( SCREEN_WIDTH - messageKeys->w ) / 2, ( SCREEN_HEIGHT - messageKeys->h ) / 2, messageKeys, screen );}so its still something in that same area i think...D:   ;  Im sorry if im making a stupid mistake!please help!   ;  Are you flipping the screen when you are done?   ;  yes I am just after this   ;  ok my bad loli was flipping the screen once then just going into an infinite check if exit loopsorry   