// Close modal with ESC key jQuery(document).keyup( function(e) { if ( e.keyCode == 27 && self.active ) { // escape key maps to keycode `27` self.close(); } });