How to make player rotate using A and D, and then stop rotating?

So I want to make it so instead of the character just moving left and right, I want it to rotate towards that direction then move in that direction, like most games, but I keep finding things that just rotate the player forever like a beyblade :frowning:

So if you press β€˜D’, the player will rotate right then move forward? If so, you can use transform.Rotate() to do this. Here’s some untested code that might do that:

public class PlayerMovement : MonoBehaviour
{
    public float RotateSpeed;

    void Update()
    {
        Rotate();
    }

    void Rotate()
    {
        // 'A' rotates left
        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(new Vector3(0f, -RotateSpeed, 0f));
        }

        // 'D' rotates right
        if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(new Vector3(0f, RotateSpeed, 0f));
        }
    }
}

@VaLightningThief