Pressed key action?

How do I implement a guarding mechanic that uses a key, for example spacebar, to guard? So as long as I am holding down space bar, I want the character to be playing the guarding animation, It would even be better if it can blend between idle/guard animation.