How to implement Quit Button in Unity

For today’s short article, I’ll be going over how to allow the player to quit the game by pressing the ESCAPE key.

Note: this is super useful only when the Unity game is a standalone build and especially when on full screen mode.

How to do it

Application.Quit() function will not work when playing the game from the editor. To test out the functionality, you must build a standalone executable of the game.

What it looks like in action

Thanks for reading!