Jump isnt working

This movement code worked in my 3d game so I copied it over to my 2d game. It will let me jump once but not again. If I remove the && then I can jump repeatedly off the ground. However my ccaharacter will keep jumping even if he’s not on the ground which is why I put in the && but that only allows me to jump once. Here’s the code:

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

public class CharacterMovment : MonoBehaviour
{
    int speed = 10;
    int jumpForce = 5;
    Rigidbody2D rb;
    bool onGround = true;


    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.A))
        {
            transform.Translate(Vector2.left * speed * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.D))
        {
            transform.Translate(Vector2.right * speed * Time.deltaTime);
        }
        if (Input.GetKeyDown(KeyCode.Space) && onGround)
        {
            rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
            onGround = false;
        }
    }

    public void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Ground"))
        { 
            onGround = true;
        }
    }
}

OnCollisionEnter” is for 3d, you are looking for “OnCollisionEnter2D


private void OnCollisionEnter2D(Collision2D col)