diff --git a/static/js/theme.js b/static/js/theme.js index a9a49f47b6..a057bf7250 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -548,6 +548,13 @@ function initMenuScrollbar(){ adjustContentWidth(); } +function imageEscapeHandler( event ){ + if( event.key == "Escape" ){ + var image = event.target; + image.click(); + } +} + function sidebarEscapeHandler( event ){ if( event.key == "Escape" ){ var b = document.querySelector( 'body' ); @@ -752,6 +759,10 @@ function initSwipeHandler(){ document.querySelectorAll( '#sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX); }, false); } +function initImage(){ + document.querySelectorAll( '.lightbox' ).forEach( function(e){ e.addEventListener("keydown", imageEscapeHandler); }, false); +} + function clearHistory() { var visitedItem = baseUriFull + 'visited-url/' for( var item in sessionStorage ){ @@ -1074,6 +1085,7 @@ ready( function(){ initSwipeHandler(); initHistory(); initSearch(); + initImage(); }); function useMermaid( config ){