hi
in order to do this you could use a condition such as "if (key_space==1)" in your entities action to initiate the animation where he is swinging the sword once space bar is pressed.
and then adding ent_cycle(the animation) after the condition.
Ent_cycle would have to be within a loop.
You would also have to set a condition which will make the sword animation stop.