- Home /
Digital Hardware Key - Android
Hi, I'm having an issue with "digital" hardware Keys (MENU, HOME, ESCAPE). What I mean is those cellphones with doesn't actually have physical bottoms instead of it, it have those "digital" "touch" bottoms. Like this model LG Optimus 3D, so the KeyDown and KeyUp does not work, only GetKey does.
So, the most common use for this keys is for Pause and I'm using for it.
var pause:boolean = false;
function PauseButton()
{
if (Input.GetKey(KeyCode.Menu))
{
if (!pause)
{
Time.timeScale = 1;
pause = true;
}
else
{
Time.timeScale = 0;
pause = false;
}
}
}
Everything is working as planed, the only issue is the GetKey thing, because when you press the key the command loops until you release the bottom. I tried a Yield pause, but I believe that is not working because of the "Time.timeScale = 0". How can I go around this?
Thanks in advance!
PS: Sorry about the bad english.
Answer by Riderrr · Feb 09, 2014 at 06:27 PM
Use GetKeyDown command
if (Input.GetKeyDown(KeyCode.Home) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Menu))
{
print("Quit");
Application.Quit();
return;
}