Whenever I jump and I press the spacebar again midair, the player jumps again as soon as it hits the ground

I’m not sure what I can do to fix it.

jumpKeyPressed can only get set to false if the player is grounded.

Instead, write your FixedUpdate function like this:

private void FixedUpdate()
    if (grounded && jumpKeyPressed)
        rb.AddForce(Vector3.up * 5, ForceMode.Impulse);
    jumpKeyPressed = false;