I’ve a textField in my script, so when I want to close my keyboard with back button, it also close the scene following this code:
if (Input.GetKey(KeyCode.Escape)) { Application.LoadLevel(0); }
Is there a way to map the back button to close the keyboard first?
Check if the keyboard is visible. Set bool isKeyboardVisible to true when bringing up the keyboard.
if (Input.GetKeyDown(KeyCode.Escape))
{
if (isKeyboardVisible)
{
HideKeyboard();
isKeyboardVisible = false;
}
else
{
Application.LoadLevel(0);
}
}
Uhm i’ve never seen this behaviour. I guess you talk about an Android build, right? The “back button” actually looks differently when the keyboard is open. The keyboard usually eats the event itself. How do you open the keyboard? Do you open it manually?