I NEED HELP!

I'm in the middle of creating a platformer, and in one section of the game the character picks up a sword. The problem is, I don't know how to get him to use it. I want to press "Spacebar" and he slashes with his sword. I am also going to animate three different attacks with the sword (For example jab, slice, and slash).

I want to press spacebar once and the character does "Attack 1." Press it again and he does "Attack 2" and etc. So what is the coding for all of this?

If somebody could resolve this I would be more than thankful.