The Escape Button is a Feature

Unity doesn’t have the a way to exit the game by default once you build it. When it’s played in windowed mode you can hit the close window button with the mouse. The problem is when you go full screen there is no button to exit the game. We need to build this functionality in manually.
Add the following code the detect the Escape key getting pressed to exit the game.

if (Input.GetKeyDown(KeyCode.Escape))

This can’t be used in the Editor. You will need to build to use this.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tristan Engel

Tristan Engel


Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.