How to hold space bar and jump? [2D]

So my problem here is that when the player holds the space button the addForce function is increased which I don’t want.

So what I want is that if a player holds the space button they can keep jumping continuously if they’re on the ground…

Here is my code:

    private void Update()
        GetComponent<Rigidbody2D>().velocity = new Vector2(1.0f * movementSpeed, GetComponent<Rigidbody2D>().velocity.y);

        if (IsGrounded() && Input.GetKey(KeyCode.Space)) 

            Debug.Log("IS JUMPING");
            _rigidBody.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);

I think the problem is base on your “IsGrounded” function. It might return true for a few frames, in which your player is already jumping, this would causes the increasing of the force applyed to your character. So you need to make sure that your “IsGrounded” function returns false instantly, after your player jumped.