Third Person Crouch walk

So my problem is this, I have a script it allows you to crouch

{
 if(Input.GetKeyDown(KeyCode.LeftControl))
 {
  // Plays the _____ animation - stops all other animations
  animation.CrossFade("crouch");
 }
}

and this one disables it when you let go

{
 if(Input.GetKeyUp(KeyCode.LeftControl))
 {
  // Plays the _____ animation - stops all other animations
  animation.CrossFade("standcustom");
 }
}

and this one allows you to walk forward, while crouching

var ctrlDown : boolean = false;
     
    function Update () {
          if(Input.GetKey(KeyCode.LeftControl)) {
              ctrlDown = true;
          }
           if(Input.GetKeyUp(KeyCode.LeftControl)) {
              ctrlDown = false;
          }
          if(Input.GetKey(KeyCode.W)) { 
             if(ctrlDown == true) {
                 animation.CrossFade("crouchwalkforward");
             } 
             else {
                 animation.CrossFade("walkcustom");
             }
          }
     }

What works: When I hit control I crouch, I let go I un-crouch, that works great. When I hit control + W, I walk forward while crouching, that part works great. However When I let go of W, while holding control, I stand, although I am not actually standing, so the camera stays but the character moves up. If I change “else” to crouch, then he is always crouching when pressing “w” so that doesn’t work. Can someone help me?

Looks like you aren’t using the right “Input.GetKey()”

There are 3 different types of GetKeys:

Input.GetKey()

Input.GetKeyDown()

Input.GetKeyUp()

GetKey() will return true as long as the button is pressed.

GetKeyDown() will only return true when the button is pressed down during that frame.

GetKeyUp() will only return true when the button is released during that frame.

Try switching everything to GetKey()

if(Input.GetKey(KeyCode.leftControl))
{
   ctrlDown = true;
}
else
{
   ctrlDown = false;
}