The Escape Button is a feature

Dennisse Pagán Dávila
2 min readMay 17, 2021
ESC button animation by Khalil Hanna

Enabling the option to exit a game or application at any time is a standard feature that should be implemented. The Unity Engine allows us to do just that in a universal way that can work for Windows, Mac, and Linux.

In today’s article, you will learn how to register the Escape button to exit an application or game.

Using Application.Quit with User Input

quit Button Source

Application.Quit is an in-engine method within the Application class that grants access to the application run-time data. This method effectively shuts down an ongoing application and can be called in response to user input.

You can place the code logic with a void method and then call it from the Update, or directly place it in the Update.

Note: Remember — All input is processed within the Update because it is called once per frame. This is of vital importance since input events like GetKeyDown and GetButtonDown, among others, are only true for one freame.

Code:

This simple code accomplishes the objective in response to user input.

In the coming articles, I will be tackling coding challenges and the process behind my problem-solving!

--

--

Dennisse Pagán Dávila

Software Engineer that specialize in Game Development. Currently looking for new opportunities. LinkedIn: https://rb.gy/xdu8nu