How to close the window and quit the application when you press ESC key under OS X? On Windows it is something common to close a window by pressing ESC key. I'm looking for a solution that would allow me to close the current Window and the application when I press ESC.

Currently the Preferences panel does not allow you to set a shortcut for ESC.

Use case: you open a file from another application inside a viewer or editor and you want to return to the initial application just by pressing ESC once.
Off the top of my head:

Downlod KeyRemap4Macbook
http://pqrs.org/macosx/keyremap4macbook/

See if you can't find a setting for escape, I'm not sure if there is one.
Remap it to Command + Q.