- Home /
Back and Menu button on the device
Yo, so I am just wondering how to make a script for menu button and back button that are on the device? With this i mean this two buttons:
I know someone have used it so please share it with me, I would really need it :))) Thankssss
Answer by MikeNewall · May 30, 2014 at 07:45 PM
mapped to the back button on the android platform in the final release of Unity 3.0. As far as other mappings I've found that the "menu" key label is mapped to the menu key and that that MonoBehaviours will get an "OnApplicationPause" + true call when the home button is pressed and an "OnApplicationPause" + false when the application is brought back as the current process. I've not found a mapping for the search button as of yet. [http://answers.unity3d.com/questions/25535/android-back-button-event.html][1] [1]: http://answers.unity3d.com/questions/25535/android-back-button-event.html The search box is there for a reason... :pThe "escape" key label appears to be
Yes thanks so i will use that : if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape)) { Application.Quit(); } But thanks anyway yes :) hope it will work :)
Noticed that post is from a while ago. I'd be interested to know if they're still mapped to the same key codes.
Yes it worked i have tested it on android device and the code you see bellow works perfectlly fine for Back button (:
Answer by alone1992 · Jan 30, 2015 at 09:20 AM
Hi dear You can use this codes for your work.
function Update () {
if (Input.GetKey(KeyCode.Home)){
//Home button pressed! write every thing you want to do
}
if (Input.GetKey(KeyCode.Escape)){
//Escape button codes
}
if(Input.GetKey(KeyCode.Menu)){
Application.Quit();
}
}
could you please tell me how to run the app in the background after the back button is pressed? thanks
Home or $$anonymous$$enu button key detection not working at all in current version of Unity. Any way exist to do this ?
Your answer
![](https://koobas.hobune.stream/wayback/20220613150300im_/https://answers.unity.com/themes/thub/images/avi.jpg)