This is not a good way to close a window. If you show a window as modal (via
), you need to use
; and the form will close itself on escape:
And if the form is not modal, you should never close it with Escape, as it will violated expected UI style and can cause loss of user's work, by apparent reasons.