Question: How do I make an application that I can make the ESC key close a window? Or really any key (I can change if I want to).

Please help. Thanks

Here is what I have and I can't get it to work.

```
-- close window with "ESC"

tell application "System Events"
    tell application "Finder" to activate
    key code 53

end tell

beep 3

```

Thanks! B-

Answer: 
Favoring separation of presentation and logic, I'd suggest you bind events to it via the Javascript:

```
document.getElementById("MyButton").onclick = function(){
  alert("Button Clicked");
}

```

Keep your Javascript and CSS out of your HTML, and you'll be a happier developer. This method allows your programmers to write the Javascript, and your Designers to build the structure and styling. You don't want to put programming into the hands of a designer (which is what happens with inline javascript).
I use the `ondomready` event to assign all my events, normally squirreled away in a separate script. All my logic is in one place and my markup looks a lot tidier too. I hold the view that markup is merely there to describe the initial structure of the page. Code lives in a code file, and styles belong in a css file.