help me check when object is not touching anything

I intended to use OnCollisionStay2D to check when object touched the ground to set “bool grounded” to “true” and set “bool grounded” to “false” when it’s not. However “grounded” is always set to “true” in game and I can call the Jump() method as many times as I want.

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] float moveSpeed = 10f;
    [SerializeField] Vector2 jumpForce;

    bool grounded;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        {
            HorizontalMovement();
            Jump();
        }
    }

        private void HorizontalMovement()
        {
            var HorizontalInput = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
            var newXPos = (transform.position.x + HorizontalInput);

            transform.position = new Vector2(newXPos, transform.position.y);
        }

        private void Jump()
        {
            if (Input.GetKeyDown(KeyCode.Space) && grounded == true)
            {
                GetComponent<Rigidbody2D>().AddForce(jumpForce);
            } 
        }

        private void OnCollisionStay2D(Collision2D collision)
        {
        if (collision.gameObject.tag == "Ground")
            {
                grounded = true;
            } else { grounded = false; }
        }
}

There is a mistakes
///////////////////

  private void Jump()
         {
             if (Input.GetKeyDown(KeyCode.Space) && grounded == true)
             {
                 GetComponent<Rigidbody2D>().AddForce(jumpForce);
           

             } 
         }

////////////////// *Solution :

     private void Jump()
     {
         if (Input.GetKeyDown(KeyCode.Space) && grounded == true)
         {
             GetComponent<Rigidbody2D>().AddForce(jumpForce);
             grounded = false;  /// you have to change "grounded" 

         } 
     }

//////////////

you have to change “grounded” = false; in Jump()

if grounded be false in Jump() , gameobject can jump just one time

because :
there is a if (condition) in jump()

   if (Input.GetKeyDown(KeyCode.Space) && grounded == true)

I added that. Now I can double jump for some reason lol.

I replaced OnCollisionStay2D with OnCollisionEnter2D and OnCollisionExit2D to modify “grounded” and it works. But why doesn’t OnCollisionStay2D work?

Does it detect when the object is no longer colliding with a “grounded” tag object or does it only detect when the object touches another object that is not tagged “grounded”?