Is there a way to unfreeze only one constraint?

I’m working on player movement, but I came upon a problem. The problem is that, if I try to move the player from left/right the player won’t instantly stop, he will keep sliding, like he is on ice.

I tried to change the Gravity scale, but that seems to screw up my jumping.

Is there a different solution, to fix the sliding?

You can try increasing the drag in rigidbody component or play with friction to see what suits you best. A new physics material can be created just like any other material and assigned to the collider instead of the renderer.

Make it so when the key is unpressed then the character stops like so:

if (Input.GetKeyUp(KeyCode.A))
{
    myRigidbody.velocity = Vector2.left * 0;
}

if (Input.GetKeyUp(KeyCode.D))
{
    myRigidbody.velocity = Vector2.right * 0;
}