On button down animation plays

I’m trying to make it so that when I push down a key, an animation will play. However I have been looking it up and trying to find a way to get that to work and everything I try has failed. Any help?

Add a custom component to trigger the animation.

using UnityEngine;
using System.Collections;

public class MyAnimationHelper: MonoBehaviour {

    public Animation myAnim;

    void Update () {
        if (Input.GetKey (KeyCode.A)) {
            myAnim.Play();
        }
    }
}

For importing/creating the animation there are several ways to add one. I’d recommend checking out Unity Connect or any number of tutorial videos online for the type of animation you want.