- Home /
C# Input.GetKey("Tab") Double Tap
Hi everyone, how do you check if a key has been tapped twice? I want to check if the tab key has been tapped once.If it has been tapped once I want to display a GUI.Box. If tab has been tapped twice I want the GUI.Box to go away.
if(Input.GetKey("Tab")){
GUILayout.Box("",GUILayout.Width(150), GUILayout.Height(35))
}
Comment
Answer by robertbu · May 28, 2013 at 05:23 AM
public class ToggleGUI : MonoBehaviour {
private bool display = false;
void Update() {
if(Input.GetKeyDown(KeyCode.Tab))
display = !display;
}
void OnGUI() {
if (display)
GUILayout.Box("",GUILayout.Width(150), GUILayout.Height(35));
}
}
I made the conversion. Link for Javascript/C# conversion.
http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html