Scripting Animations to player controls

How do I “attach” an animation that I have imported from maya to a button that a player would press to control a character? For example, I have an animation of a character running, how do I make it so that when the player hits “w” or the “forward button” and the camera moves, the character also appears to be running? (displays the animation) I do not know the script nor the process for this. Any help would be great.

animation.play(“running”);

in the “” name of the animation you choosed when importing

sorry for the bad english

if (input.GetAxis(“Vertical”));

animation.Play(“name of animation”);

im still kinda new to all of this. but i believe that that is the gist of it

So I add that javascript to the character, but how do you get the “w” key to trigger the animation? I am also new sorry if that is a stupid question. Thanks for the reply guys I’m gonna give it a whirl again.