starting position when holding down a key

Quick newb question. I have an object in my scene with this simple code applied to it to move left and right:

function Update () {
if (Input.GetKey(KeyCode.A)){
    transform.Translate(Vector3(1*Time.deltaTime*speed,0,0));
        }else{
        if (Input.GetKey(KeyCode.D)){
            transform.Translate(Vector3(1*Time.deltaTime*speed,0,0));
    }
}

my question is, how do I have it so that if I press A, the gameObject will position itself 2 unit to the right and then start translating? I'm guessing I can use transform.position.x+=2, but how do I implement this so it'll work inside the code? Thanks

Place your initial translation inside an if(Input.GetKeyDown(KeyCode.A)) which will only happen the first frame the button is held down.

function Update() {
    if(Input.GetKeyDown(KeyCode.A)) transform.position += 2.0f;
    //other stuff...
}