- Home /
Back button issue: when I use back button to close keyboard, it also close the scene.
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?
Put the close keyboard function before you load the level???
Answer by giano574 · Oct 25, 2014 at 12:34 AM
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);
}
}
Hide$$anonymous$$eyboard();
doesn't exist. If I have to make it, what command have I to put in? There's no command to close the keyboard, even a TouchScreen$$anonymous$$eyboard one.
Answer by Bunny83 · Oct 25, 2014 at 01:19 AM
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?
It opens simply tapping in the field. Yes it's about Android