[2d] Player sometimes doesn't jump up while moving and jumping at the same time

My issue is that the player sometimes (occasionally) doesn’t jump up while moving. It sometimes works, sometimes don’t. It’s weird, here’s the code:

[SerializeField] private LayerMask platformsLayerMask;

public Rigidbody2D rb;

public float MovementSpeed = 100f;

public float JumpingHeight = 100f;

public BoxCollider2D bc;

public float fallMultiplier = 2.5f;
public float lowJumpMultiplier = 2f;

void Awake()
{
    rb = transform.GetComponent<Rigidbody2D>();
    bc = transform.GetComponent<BoxCollider2D>();
}

void FixedUpdate()
{
    if (IsGrounded() && Input.GetKeyDown(KeyCode.Space))
	{
        rb.velocity = new Vector2(rb.velocity.x, JumpingHeight * Time.deltaTime);
        Debug.Log("Jumping");
    }
    HandleMovement();

}

private bool IsGrounded()
{
    RaycastHit2D raycastHit2d = Physics2D.BoxCast(bc.bounds.center, bc.bounds.size, 0f, Vector2.down, 1f, platformsLayerMask);
    Debug.Log(raycastHit2d.collider);
    return raycastHit2d.collider != null;
}

void HandleMovement()
{
    if (Input.GetKey(KeyCode.A))
    {
        rb.velocity = new Vector2(-MovementSpeed * Time.deltaTime, rb.velocity.y);
        Debug.Log("Going Left");
    }
    else
    {
        if (Input.GetKey(KeyCode.D))
        {
            rb.velocity = new Vector2(+MovementSpeed * Time.deltaTime, rb.velocity.y);
            Debug.Log("Going Right");
        }
        else
        {
            //no keys pressed
            rb.velocity = new Vector2(0, rb.velocity.y);
            Debug.Log("No key pressed");
        }
    }
    if (rb.velocity.y < 0) //reponsive jumping and falling
    {
        rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
    }
    else if (rb.velocity.y > 0 && Input.GetKeyDown(KeyCode.Space))
    {
        rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
    }

}

}

Hello, the problem is because you try to get spacebar down in FixedUpdate. However, FixedUpdate may not run in all frames like Update, so what happens is that sometimes you press the Space button when FixedUpdate has not been called yet, and so it reverts to false in the next frame. What you can do is assigning it to a boolean in Update like this:

void Update(){
   if(Input.GetKeyDown(KeyCode.Space){
     hasPressedJump = true;
   }        
}

void FixedUpdate(){
   if(IsGrounded() && hasPressedJump){
     //your code
     hasPressedJump = false;
   }
}