You're better off doing just one check for #UP and one for #DOWN, put a VSYNC at the end of your loop too. Do it like this: IF B AND #DOWN THEN IF S==2 THEN DO THIS ELSEIF S==3 THEN DO THIS ENDIF ENDIF Then do the same for #UP.