Implimenting Animations in script

How would i impliment an animation in a script say a shoot script to make it play the animation clip

var PlayShoot = true;

function Update()
{
 if(Input.anyKeyDown)//when any key is pressed
 {
  PlayShoot = true;//tell it to play animation
 }
 if(PlayShoot)//play animation?
 {
  animation.Play("AnimationNameHere");//code for playing animation (by name)
  PlayShoot = false;
 }
}

of course, you have to rename the animation in the code, and you can change the way you tell it to play your animation.