Keep in mind that you may have conditions that are in conflict.
Say you hit space while moving (he tries to slash) but then you also hit forward (which might be making your character set the animation to walk instead).
Without a cap.x its pretty hard to give you an answer, as you could have coded up your game in 1 of 1 million ways.