change animator parameters with the input system

Hello Everyone. I have a character’s animator with a simple animation tree. Transitions between animation states are using boolean variables. I just want to know how to change these boolean variables when I input a button.
For example, when pressing “W” on the keyboard the “isWalking” becomes true.

Write a MonoBehaviour that listens for input and sets the parameter value and attach it to your game object. Something like…

using UnityEngine;

public class MovementAnimationListener : MonoBehaviour
{
    public Animator MyAnimator;

    void Awake()
    {
        MyAnimator = GetComponent<Animator>();
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            MyAnimator?.SetBool("isWalking", true);
        }
        else if (Input.GetKeyUp(KeyCode.W))
        {
            MyAnimator?.SetBool("isWalking", false);
        }
    }
}