diff --git a/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js b/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js index 93260d9bb8..736c378ed8 100644 --- a/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js +++ b/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js @@ -1,12 +1,16 @@ -jQuery( document ).ready( function( $ ) { - $( document ).keydown( function( e ) { +jQuery( function( $ ) { + $( document ).on( 'keydown.twentyfourteen', function( e ) { var url = false; - if ( e.which === 37 ) { // Left arrow key code + + // Left arrow key code. + if ( e.which === 37 ) { url = $( '.previous-image a' ).attr( 'href' ); - } - else if ( e.which === 39 ) { // Right arrow key code + + // Right arrow key code. + } else if ( e.which === 39 ) { url = $( '.entry-attachment a' ).attr( 'href' ); } + if ( url && ( !$( 'textarea, input' ).is( ':focus' ) ) ) { window.location = url; }