One option is to create "states" using variables.
ie. create variable called states=0 and then change it for example:
idle states: state=0
running state: state=1
jumping state: state=2
attacking state: state=3
You can then stop/start animations/events based on the conditioning of these variables.
Example: Space bar pressed, change state to 3. If state=3 run animation stops.