I think you should try to do it differently.
Say, on key pressed 'Right' -> play 'Walk' animation.
There's got to be an event before everything.
So, on key pressed 'Space' -> play 'Fly' animation.
If 'Player' is on collision with 'Ground' -> Stop 'Fly' animation.
That sorta thing. I'm not sure what you're making, but it helps to be creative and reading tutorials helps with that :P