Bind a key to close game

I want to bind a key to be able to close the game window or reset my game and put me where I started

// Quits the player when the user hits escape
function Update () {
if (Input.GetKey (“escape”)) {
Application.Quit();
}
}

you make a empty gameobject and attach this script to it script:

C#:
public KeyCode yourButton;

void Start()
{
    DontDestroyOnLoad(gameObject); //this makes the GameObject go through all the scenes. That means, this will work in every scene in the game.
}

void Update()
{
    if (Input.GetKeyDown(yourButton))
    {
        Application.Quit();
        Debug.Log("Application has been quit!");
    }
}

JavaScript:

#pragma strict

var yourButton : KeyCode;
    
function Start()
{
    DontDestroyOnLoad(gameObject); //this makes the GameObject go through all the scenes. That means, this will work in every scene in the game.
}

function Update()
{
    if(Input.GetKeyDown(yourButton))
	{
        Application.Quit();
		Debug.Log("Application has been quit!");
	}
}