Level Up Your Unity Skills: Escape Button as a Feature

Gerald "Ray" Patton
1 min readApr 25, 2024

--

Objective: Program the ability the quit the game by using the Escape Button.

So I have a game that allows me to play it, but only in Windowed Mode. If I attempt to play it in Fullscreen, the only way I can quit the game is by using Windows Taskmanager. This is very inconvenient. So, I did a some research online found a way to Quit the Application by adding an Input Key method.

Looking a Unity’s Scripting API, I found Application.Quit class. The code for this looks like this:

I noticed in the Scripting API the following line “ The Application.Quit call is ignored in the Editor.” What that means, is that in order to test it, I had to make a build. For more information on how to make a build in Unity, refer to the link below:

My build and test was successful. Until next time, Happy Developing!

--

--

Gerald "Ray" Patton

Unity Developer | C# Software Engineer | Game Developer | USAF Veteran