I need a character animation script

my character has a seperate move script and I want to animate it. I need the animation script that makes it that you press a key and it animates just a code would do also. Please help

The animation.Play() function is deprecated. Use this instead.

function Update ()
{
    if(Input.GetKey(KeyCode.W))
    {
        GetComponent.<Animation>().Play("walk");
    }
    else
    {
        GetComponent.<Animation>().Play("idle");
    }
}

I would HIGHLY recommend using an animator if you want transitions between animations.

Also, I just recently started writing scripts for free for anyone who needs them. Email me at duskerstudios@gmail.com if you want a scripter.

This page explains clearly how you would script input based animation events:

http://unity3d.com/support/documentation/Manual/Animation%20Scripting.html

So for example:

function Update () {
   if (Input.GetAxis("Vertical") > 0.2)
       animation.CrossFade ("walk");
   else
      animation.CrossFade ("idle");
} 

This plays the animation "walk" when the player moves forward or backwards.