Stop playing animation when key is not anymore pressed.

So im trying to make this camera bobbing animation, but when i stop pressing W the animation doesnt stop.
If someone could add something to the script below to make it stop when the w key is not pressed it will be awesome. :slight_smile:

#pragma strict

var MainCamera : GameObject;

function Start()
{
    MainCamera = GameObject.Find("Main Camera");
}  

function Update ()
{
if(Input.GetButtonDown("w"))
{
  // Plays the reload animation - stops all other animations
  animation.Play("camBobbing_", PlayMode.StopAll);

   }
}

You can make another state like camIdle and make this as the default.
Then just set the triggers to transition between idle and bobbing animations.