game snake move

how can I make sure to tell my object when I press the right arrow he must go infinitely right? and when I click the left must do the opposite? I have tried using if (Input.GetAxis) but right when I remove your finger from the button stops this is the script:

#pragma strict

 

function Start () {

 

 

 

}

 

function Update () {

 

  if(Input.GetAxis("Vertical")>0){

  

  transform.Translate(0,0,5.0*Time.deltaTime);

  }

  

  }

You could have a “last direction pressed” of sorts, and instead of using the vertical axis on the Input directly, use the Input to change the last pressed direction, and use the traslate at all time (outside the If input statement) using the last direction pressed.