Why doesn't this script work?

So i was trying to make an animation play when the speed is 0 and when it isnt 0.
Turns out that’s not how it works, so it just made me not move at all with the idle animation. Please help me fix this script.

         void Update()
        {
        if(Input.GetKeyUp("a"))
        {
            speed = 25;
        }
        else
        {
            speed = 0;
        }

        if(Input.GetKeyUp("d"))

        {
            speed = 25;
        }
        else
        {
            speed = 0;
        }

       if(speed != 0f)
       {
          playerAnimator.SetBool("isRunning", true);
       }
       else
       {
          playerAnimator.SetBool("isRunning", false);
       }

Hello.

Did you know there are 3 Getkey funtions?

GetKey(): All frames while is pressed

Getkeydown(): The first frsme is pressed

Getkeyup(): The next frame after is released.

Goo find unity documentation about all 3.

Also, this code still needs the closing } for the update function.

Bye!