Creating a walking animation. Need help!

Hi, I am making a first person horror game and I want to make a walking animation for my player. I have created the script and the animation, where the player moves up and down as he walks. The script works fine but when I move, the player just moves up and down. It must be something got to do with the animation. Here’s the script if you need it.

function Update()
{
	if(Input.GetKeyDown(KeyCode.W))
	{
		animation.Play("Walk");
	}
	
	if(Input.GetKeyDown(KeyCode.A))
	{
		animation.Play("Walk");
	}
	
	if(Input.GetKeyDown(KeyCode.S))
	{
		animation.Play("Walk");
	}
	
	if(Input.GetKeyDown(KeyCode.D))
	{
		animation.Play("Walk");
	}
}

You may need to check if the animation is already playing, because you will always play the first frame of your animation if not :

function Update()
{
    if(Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))
    {
        if (!animation.IsPlaying("Walk")) animation.Play("Walk");
    }
}