Animation working when space bar is pressed