catch ESC

it would be great to have a possibility to catch ESC so that i doesn’t necessarily quit the app.
for example to show a dialog screen like: do you really want to quit?
or to implement other functionality like clearing the line of an input box.
in my own app i often do things like that with either having the handler return false (key not handled) or true (key was recognized and handled).