How to move a Gameobject horizontally changing its position?

Hi, I want to move horizontally some gameobjects, not by the Input.GetAxis but with something like transform.Translate or adding a value to position.x but the problem I have is that when I press the right or left key, the number of iterations are at least 3, how could I avoid so many iterations? I just want to move once every time I press the direction keys

Thank you.

C#

 public class Movement : MonoBehaviour {
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		float x = 0;
		
        if (Input.GetKey(KeyCode.D))
        {
            x = 1;
        }
        transform.Translate(x,0,0);

		 float z = 0;
		
        if (Input.GetKey(KeyCode.A))
        {
            z = -1;
        }
        transform.Translate(z,0,0);
		
		
	}
}

I wrote that a bit ago you can adjust the iterations i’m pretty sure :slight_smile: hope it helps

Yeah, thank you all of you, I wrote

			if (Input.GetKeyDown(KeyCode.D))
				transform.Translate(MovHor,0,0);
			if (Input.GetKeyDown(KeyCode.A))
				transform.Translate(-MovHor,0,0);

And I get the behaviour I wanted