you could setup for the keyboard control only direction variables and on the forward or thrust button a speed variable. If you collide overwrite the speed variable to 0 so that if you multiply the direction variable with the speed variable you reach 0 distance in shifting.
dirx = -1;
myMc._x += dirx *speed;
Of course like Djugan already said, depending on how your game works (concept wise) it can be implemented in many different ways.