Close Window(s) on escape key

If anyone wants to know how to quickly enable the ESC key to close just the topmost windw, here’s some code snippet (and more on how to integrate with jQuery):

jQuery(document).ready(function() { 
        initdhxwins();
        jQuery(document).keyup(function(event) {
            if (event.which == 27 ) {     // ESC Key
                 // close current focussed dhx window:
                 var topwin = dhxWins.getTopmostWindow(false);         
                 if ( topwin != null )
                 {
                     topwin.setModal(false);
                     topwin.hide();
                     // or: topwin.close();
                 }
            }
            event.preventDefault(); // important: fall through event
        });
    });

have fun,
Axel