Escape Buton?

EDIT: Unity was just being dodgy or something. I opened it up this morning and there were no errors. Tested it, and it worked. Exact same script as before.

Escape button (not “buton”) doesn’t exist?

What I need is to have it so that pressing the “escape” button takes me to the Main Menu (index 0 in the build list). I have the script in an empty object, along with my working restart script. But apparently, escape isn’t a button. I’ve also tried “esc” and “Esc” and all that.

First I tried this (and various changes like removing the capital letter and putting it in quotes and stuff):

function Update () 
{
        if (Input.GetKeyDown(KeyCode.Escape) {
            Application.LoadLevel (0);
        }
}

Then I tried this from Unity - Scripting API: Application.Quit and changed it to:

function Update () 
{
        if (Input.GetKey ("escape")) {
            Application.LoadLevel (0);
        }
}

But it still came up with an error saying escape doesn’t exist, even with me making the same changes to it as the original script I made.

So I don’t have a clue what to do. Any ideas?

I don’t see anything wrong with your first snippet, which I replicated below:

    function Update ()
    {
            if (Input.GetKeyDown(KeyCode.Escape) {
                Application.LoadLevel (0);
            }
    }

If you replace the Application.LoadLevel with a Debug.Log message, do you get the message?

Nope. It comes up with an error saying escape ,or whatever variant of it I change it to, doesn’t exist.

Post the code you are using and the actual error you’re getting.

There is no “variant” of a keycode. The docs are definitive so there’s no reason to guess. The code I posted (your code) should be correct.