At the beginnig of your code for movement, have it set a variable, let's say, "moving" (how obvious), to 1, and when he's not moving (AKA, no direction keys are being pressed), have it set to 0. Then have it check if moving=1 at the beginning of the rolling code.