Application.Quit(); on GetKey not working.

// Quits the app when the user hits x key
function Update () {
if (Input.GetKey (“x”)) {
Application.Quit();
}
}

For some reason this code won’t exit the app. Why is this? Thanks.

Try this one maybe:

if(Input.GetKeyDown(KeyCode.X)){
    Application.Quit();
}

Also remember that Application.Quit() won’t work if you are using it inside the editor, it needs to be on a built game to work.

From the documentation: Quit is ignored in the editor.

Thanks, got it going. Had the script turned off in the editor. :slight_smile: