How do I make a character jump only once in Unity 2D?,How do I make a character Jump only once?

When I press the “Space” or “W” Key assigned to jump, I am able to continously jump in midair. How am I able to limit this to a double jump in the Rigidbody2D?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
private Rigidbody2D rb2d;
public float speed;
private bool Constraint;
private Animator animCharacter;
public Vector2 JumpVelocity;
public float jump;
float moveVelocity;
bool grounded = false;

void Start()
{
    rb2d = GetComponent<Rigidbody2D>();
    animCharacter = GetComponent<Animator>();
}
 void FixedUpdate()
{

    if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown (KeyCode.W))
    {
        rb2d.velocity = new Vector2(rb2d.velocity.x, jump);
        animCharacter.SetTrigger("Jump Activated");
        
    }

    rb2d = GetComponent<Rigidbody2D>();
    if (rb2d.velocity.y == 0)
    {
        animCharacter.SetTrigger("Grounded");

    }

    if (Input.GetKey(KeyCode.D)) rb2d.velocity += Vector2.right * speed;

    if (Input.GetKey(KeyCode.A))
    {
        rb2d.velocity = new Vector2(-speed, rb2d.velocity.y);
    }
    else if (Input.GetKey(KeyCode.D))
    {
        rb2d.velocity = new Vector2(speed, rb2d.velocity.y);
    }

    else
        rb2d.velocity = new Vector2(0, rb2d.velocity.y);
}

}
,When I press the “Space” or “W” keys assigned to Jump, I am able to continously jump in midair. How am I able to fix this?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
private Rigidbody2D rb2d;
public float speed;
private bool Constraint;
private Animator animCharacter;
public Vector2 JumpVelocity;
public float jump;
float moveVelocity;
bool grounded = false;

void Start()
{
    rb2d = GetComponent<Rigidbody2D>();
    animCharacter = GetComponent<Animator>();
}
 void FixedUpdate()
{

    if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown (KeyCode.W))
    {
        rb2d.velocity = new Vector2(rb2d.velocity.x, jump);
        animCharacter.SetTrigger("Jump Activated");
        
    }

    rb2d = GetComponent<Rigidbody2D>();
    if (rb2d.velocity.y == 0)
    {
        animCharacter.SetTrigger("Grounded");

    }

    if (Input.GetKey(KeyCode.D)) rb2d.velocity += Vector2.right * speed;

    if (Input.GetKey(KeyCode.A))
    {
        rb2d.velocity = new Vector2(-speed, rb2d.velocity.y);
    }
    else if (Input.GetKey(KeyCode.D))
    {
        rb2d.velocity = new Vector2(speed, rb2d.velocity.y);
    }

    else
        rb2d.velocity = new Vector2(0, rb2d.velocity.y);
}

}

Good day.

This is a very basic and common thing. There are a lot of questions answered about this, a çot of youtube tutorials and manuals. Go look for them.

Bye.