- Home /
No code snippet provided & asked for debugging
how do make the escape key make you leave the game
hi i am new to unity and only know minimal about coding is there a way to make the escape key make me leave the game when i try it says fix all compiler errors before you add it in but everything is correct please help and remember i am new so i might not know were some things are thanks
You could have googled it though.
if(Input.Gey$$anonymous$$eyDown($$anonymous$$eycode.Esc)){
Application.Quit();
}
Frequently Asked Questions https://answers.unity.com/page/faq.html
Some reasons for getting a post rejected: - You haven't provided enough context: we need more information about your problem, relevant code snippets and what you have tried already. - Asking us to fix your code: more than likely, you simply need to get a better understanding of basic program$$anonymous$$g. Having a look at the Scripting tutorials on the Learn page will help you become more familiar with scripting in Unity
Answer by neosca · Dec 02, 2017 at 08:02 AM
Try the below code in the Update function:
void Update(){
if (Input.GetKeyDown (KeyCode.Escape)) { // check if Escape key is pressed
Application.Quit (); // Quit the application
}
}