Im not sure, but I think that you want something like this…
var keyA : int = 0;
if(Input.GetKeyDown(Keycode.A)){ //We pressed key A
if(keyA ==0)keyA = 1; //If keyA is 0 then set it to one
else(keyA == 1)keyA =2; //If keyA is 1 then set it to two
}
else if(keyA==2){
//Double tapped so we reset
keyA =0;
}
else{
//This mean there is only 1 key pressed or no key is pressed
//You need to add time here, after 1 sec keyA will be again 0
}
Axis code(Double tap)(JS):
var hzH : int = 0;//Axis
var hzSwitch : boolean = false; //Switch
var pressedTime : float; //Time
function Update ()
{
//If pressed twice
if(hzH==2){
Debug.Log("HE PRESSED IT TWICE :O"); //Random text ;)
pressedTime = 0; //Return time value
hzH=0; //Return press value
}
if(hzH==1){ //If we pressed once count down seconds
pressedTime += Time.deltaTime;
}
//We pressed anything?
if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical"))
{
if(Input.GetAxis("Horizontal") >0 && hzH<2){
hzSwitch = true; //We preseed horinzontal
}
}
else if (hzSwitch && pressedTime<=2){ //Time is not up? We must press again that axis to turn on hzSwitch
if(hzH==0){hzH=1;hzSwitch = false;}
else if(hzH==1){hzH=2;hzSwitch = false;}
}
if(hzH==1 && pressedTime>=2){ //We only pressed it once and time is up
pressedTime=0;
hzH=0;
}
}