Climbing Ladder script problem

hello everyone, I made a climbing ladder script and I wanted the player to get stuck once the player is on the ladder. But somehow when I press the button just once the player moves up or down infinitely and it won’t stick on a certain part of the ladder.

here’s my code:

private void ClimbLadder()
    {
        if (!baCollider2D.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
           baRigidBody.gravityScale = gravityScaleAtStart;
           return;
        }
        if (Input.GetKey("w") || Input.GetKey("up"))
        {
            baRigidBody.velocity = new Vector2(baRigidBody.velocity.x, climbSpeed);
            baRigidBody.gravityScale = 0f;
        }
        else if (Input.GetKey("s") || Input.GetKey("down"))
        {
            baRigidBody.velocity = new Vector2(baRigidBody.velocity.x, -climbSpeed);
            baRigidBody.gravityScale = 0f;
        }

I recorded the video for some reference:

Thanks in advance.

use add force instead of velocity

when you set the velocity your character will never stop unless you set velocity back to 0.