How can I make a animation start by pressing e certain key?

I want to make a boy that is walking on a 2D World . I want to make it when I press right arrow to play animation that is included in the boy sprite and when I press left arrow to change direction horizontally and play the animation that is included - Sorry for bad English

    using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {
 
 public bool animation_bool;
 
          void Update()
                     {
 
              if(animation_bool == true)
                     {
                 animation.Play("Boy");
 
                     }
 
 
            if(Input.GetButtonDown("d"))
                     {
               animation_bool = true;
 
                     }
 
 
 
                }
}

You need to provide the KeyCode instead of a string representation of it

line 18 should be

if(Input.GetButtonDown(KeyCode.D))

you should try this.

public class PlayerController : MonoBehaviour {
   
   public bool animation_bool;
   
         void Update() {
		 if ( Input.GetAxis( "Horizontal" ) != 0 ||  Input.GetAxis( "Vertical" ) != 0 ) {
		 animation_bool = true;
		 }
		 else {
		 animation_bool = false;
		 }
		 if(animation_bool == true) {
		 animation.Play("Boy");
		 }
		 }
   }