Jumping by using unity input system

hi, I have a jumping script the longer you press the higher it jumps I have tried to implement it into the unity input system but some bugs were happening like it was sliding in air.

here is the code for the unity input system:

 public void Jump(InputAction.CallbackContext context)
    {
        if (stun == false)
        {
            if (jumpTimer > Time.time && onGround && context.performed)
            {
                animator.SetTrigger("takeOf");
                Jump();
            }
            else
            {
                animator.SetBool("isJumping", true);
            }
        }
        else
        {
            rb.gravityScale = gravity;
            rb.drag = linearDrag * 0.15f;
            if (rb.velocity.y < 0)
            {
                rb.gravityScale = gravity * fallMultiplier;
            }
            else if (rb.velocity.y > 0 && context.canceled)
            {
                rb.gravityScale = gravity * (fallMultiplier / 2);
            }
        }
    }

original code:

void FixedUpdate()
    {
            if (jumpTimer > Time.time && onGround)
            {
                animator.SetTrigger("takeOf");
                Jump();
            }
            else
            {
                animator.SetBool("isJumping", true);
            }
            modifyPhysics();
             
    }

void Jump()
    {
        rb.velocity = new Vector2(rb.velocity.x, 0);
        rb.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
        jumpTimer = 0;
    }

void modifyPhysics()
    {
        if(!onGround)
        {
            rb.gravityScale = gravity;
            rb.drag = linearDrag * 0.15f;
            if (rb.velocity.y < 0)
            {
                rb.gravityScale = gravity * fallMultiplier;
            }
            else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
            {
                rb.gravityScale = gravity * (fallMultiplier / 2);
            }
        }
    }

I was actually JUST trying to do this, here is what i have so far.

if (Input.GetKeyDown("Space") && onGround)
        {
            onGround = false;
            Jump();
        }
        else if (rb.velocity.y > 4 && Input.GetKeyDown("Space"))
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * .9f);

the bottommost line is what does the jump modifying, i just have this in update.

the script isn’t prefect yet but i think it is pretty good, i havent found any big issues with it.