Animator bool keep flickering on and off

I wanted to create a crouch toggle for my character, so that when I press a key my character will stay in the crouch animation.
However when I try this with a bool, the bool simply keep flickering when I press the assigned key
flickering
flickering2
…which is quite amusing but not very helpful

This is the part of the codes that handles crouching animation

    // Update is called once per frame
    void Update()
    {

        bool isrunning = animator.GetBool("isRunning");
        bool isWalking = animator.GetBool("IsWalking");
        bool isCrouching = animator.GetBool("isCrouching");
        bool isBackwards = animator.GetBool("isBackwards");
        bool forwardPressed = Input.GetKey("w");
        bool runPressed = Input.GetKey("left shift");
        bool crouchpressed = PlayerMovement.isCrouching;
        bool backwardPressed = Input.GetKey("s");

        // Toggle Crouch
        if (crouchpressed && !isCrouching)
        {
            animator.SetBool("isCrouching", true);
        }

        else if (crouchpressed && isCrouching)
        {
            animator.SetBool("isCrouching", false);
        }

And here is the part in the character controller that lets the animator knows if my character is crouching

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    private CharacterController controller;
    public float speed = 5f;
    public float runSpeed = 10f;
    public float crouchSpeed = 1f;
    public float backwardsSpeed = 2f;
    public float crouchBackwardsSpeed = 1f;
    public float turnSpeed = 180f;
    public bool isCrouching = false;


    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        controller = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl) && !isCrouching)
        {
            isCrouching = true;
            Debug.Log(isCrouching);
        }
        else if (Input.GetKeyDown(KeyCode.LeftControl) && isCrouching)
        {
            isCrouching = false;
            Debug.Log(isCrouching);
        }

Have been stuck for a few days, decide to seek help in case it is something very obvious

Your code should work as expected. Do you use Events in your Animations or Conditions in Animator transitions ?

Also if you want to give it a try, the best way to make inputs is to use the Input System. This is particularly useful for assigning several buttons to the same action without having to modify a script.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Actions.html

Maybe it’s because the bool animator is not the same value as your script bool ?
Try this:

        if (crouchpressed && !isCrouching)
        {
            animator.SetBool("isCrouching", false);
        }

        else if (crouchpressed && isCrouching)
        {
            animator.SetBool("isCrouching", true);
        }

In line 20 in your first code snippet, you need to have !crouchpressed not crouchpressed