How to implement a isJumping bool?

I need a way to check if the player character is jumping or not. The bool needs to enabled when the player presses the jump button and disable when they touch the ground. I’m using the new input system to detect the keypresses.

My current code consists of an isGrounded bool controlled by Rigidbody2D.IsTouching. The jump function checks if this bool is true and executes a jump followed by enabling isJumping. In update, isJumping is disabled in the ground check:

void Update()
{

    if (rigidbody2d.IsTouching(ground))
    {
        isGrounded = true;
        isJumping = false;
    }
    else
    {
        isGrounded = false;
    }
}

public void Jump(InputAction.CallbackContext context)
{
    if (isGrounded)
    {
        rigidbody2d.gravityScale = 2 * jumpHieght / (-Physics2D.gravity.y * jumpTime * jumpTime);
        rigidbody2d.AddForce(Vector2.up * 2 * jumpHieght / jumpTime, ForceMode2D.Impulse);
        isJumping = true;
    }
}

The problem seems to be that the position of the rigidbody does not change fast enough. Maybe there needs to be a delay, but how do I go about adding that and is there a better solution?

Nvm, fixed

public class PlayerScript : MonoBehaviour
{
    void Update()
    {

        if (rigidbody2d.IsTouching(ground))
        {
            isGrounded = true;
            if (!desiredJump)
            {
                isJumping = false;
            }
        }
        else
        {
            isGrounded = false;
            if (desiredJump)
            {
                isJumping = true;
                desiredJump = false;
            }
        }
    }

    public void Jump(InputAction.CallbackContext context)
    {
        if (isGrounded)
        {
            rigidbody2d.gravityScale = 2 * jumpHieght / (-Physics2D.gravity.y * jumpTime * jumpTime);
            rigidbody2d.AddForce(Vector2.up * 2 * jumpHieght / jumpTime, ForceMode2D.Impulse);
            desiredJump = true;
        }
    }
}