Escape from Unity!
Our game should be user-friendly. Part of a great user experience is giving them control over what is running on their devices. So let’s give them a quick way of exiting our game: By pressing the Escape key.
We can put this simple script in the Update method of an empty game object in our scene:
That’s it! So simple!