How can I code in a way that if I press the first time left ctrl to trigger an animation and the second time when I press left ctrl to trigger another animation?

I want to make my character to go from idle - > crouch when I first press the left ctrl and the second time when I press left ctrl to go from crouch → idle.

if(Input.GetKey(KeyCode.LeftControl)){
			anim.SetBool("CrouchOn",true);
			crouch = true;
		}
     if(crouch == true && Input.GetKey(KeyCode.LeftControl)){
			anim.SetBool("CrouchOn", false);

			crouch = false;
		}

I feel that the code would create an infinite loop because both conditions need left ctrl to be pressed in order to trigger the animation but i have no idea how to trigger one animation per click.
This is the code so far,if anyone can help I would appreciate it a lot!

if(Input.GetKey(KeyCode.LeftControl)){
anim.SetBool(“CrouchOn”,true);
crouch = true;
}
// if previous condition is true, then automaticatly this one is true
// so anim “CrouchOn” ends the frame as false . It doesnt matter
// what you did with that value previous lines
if(crouch == true && Input.GetKey(KeyCode.LeftControl)){
anim.SetBool(“CrouchOn”, false);
crouch = false;
}

What you can do is something like this

if ( Input.GetKeyDown ( KeyCode.LeftControl ) ){
    crouch = !crouch;
    anim.SetBool ( "CrouchOn", crouch );
}

This way, every time you press the left control, it changes the value of CrouchOn

That script you have for GetKey runs as long as you hold down the key, what you need to do is change from GetKey to GetKeyDown.

I believe it should work exactly like you want it to if you change those, let me know.