The Escape Key in Unity

Sherry Fisher
Oct 25, 2023

--

Objective: Create a way for the player to close the game.

At this point, I need to create a way for the player to quit the game when in full screen. Once again, Unity makes this task simple.

I want the player to be able to quit the game when they hit the escape key. So I go to my GameManager script and add the following:

Unfortunately, this doesn’t work in the Unity Editor, so you would need to create a build to test.

For more information, check out the Unity Manual: https://docs.unity3d.com/ScriptReference/Application.Quit.html

--

--