move player inifite in two directions

so i been find on google for a while but cant find the answer, i need my player 2d to move infite on two directions, left and right, like when i press ¨A¨ the player change direction to left and still running till i press ¨D¨, i hope you can help me

I Think it might be something like this. You don’t mention if you want to run left and right. it sounds like you want to run left with A for an infinite amount of time and then stop the player with D… but how would they go right? so I assumed you want both left and right. (and the option to press “S” and stop the player completely.)
_

public bool runningLeft;
public bool runningRight;

void Update()
{
    if (runningLeft)
    {
        transform.Translate(Vector2.left * Time.deltaTime);
    }

    if (runningRight)
    {
        transform.Translate(Vector2.right * Time.deltaTime);
    }

}

if (Input.GetButtonDown(KeyCode.A))
{
    runningLeft = true;
    runningRight = false;
}

if (Input.GetButtonDown(KeyCode.D))
{
    runningLeft = false;
    runningRight = true;
}

if (Input.GetButtonDown(KeyCode.S))
{
    runningLeft = false;
    runningRight = false;
}