Lately I’ve been using UIkit a lot. Although it’s a pretty elaborate set of tools with not too many bugs, the user-base seems rather small so looking for help often leaves you in the dark.
One issue I ran into was that the lightbox doesn’t close when pressing the escape key. Seems like a UX problem to me, but searching Google for anyone with the same question returned no results. Being determined enough, I dove into the mechanics of the lightbox and found out it’s basically the “modal” component with a bunch of presets specific to a lightbox. So looking at the modal functionality, it appeared you can target the lightbox element and fire a “hide” method on it when the esc key is pressed.
jQuery( document ).on( 'keyup', function( e ) {
var modal = UIkit.modal( '.uk-modal' );
if ( e.keyCode === 27 && modal.isActive() ) {
modal.hide();
}
} );
Thanks, exactly what I was looking for!