Player keeps accellerating!

Hi. I made this simple movement script but i have a problem : the character keeps accellerating. How can i set a “max speed” ? (I’m a total noob, don’t tell me too complicated stuff xD)

#pragma strict

public var Speed = 10;

function Update () {

if (Input.GetKey(KeyCode.A))
   rigidbody2D.AddRelativeForce (Vector2(-1,0) * Speed);
if (Input.GetKeyUp(KeyCode.A))
   rigidbody2D.AddRelativeForce (Vector2(0,0));
   

if (Input.GetKey(KeyCode.D))
   rigidbody2D.AddRelativeForce (Vector2(1,0) * Speed);
if (Input.GetKeyUp(KeyCode.D))
   rigidbody2D.AddRelativeForce (Vector2(0,0));


}

A simple solution to cap the maximum speed would be to find the magnitude of your velocity (the distance of the vector 2), and to clamp it down if necessary.

if (rigidbody2D.velocity.magnitude > [MAX_SPEED])
{
    rigidbody2D.velocity = rigidbody2D.velocity.normalized * [MAX_SPEED];
}