wp/wp-content/themes/twentysixteen/js/keyboard-image-navigation.js
changeset 8 c7c34916027a
parent 7 cf61fcea0001
child 9 177826044cd9
equal deleted inserted replaced
7:cf61fcea0001 8:c7c34916027a
     1 /**
       
     2  * Twenty Sixteen keyboard support for image navigation.
       
     3  */
       
     4 
       
     5 ( function( $ ) {
       
     6 	$( document ).on( 'keydown.twentysixteen', function( e ) {
       
     7 		var url = false;
       
     8 
       
     9 		// Left arrow key code.
       
    10 		if ( 37 === e.which ) {
       
    11 			url = $( '.nav-previous a' ).attr( 'href' );
       
    12 
       
    13 		// Right arrow key code.
       
    14 		} else if ( 39 === e.which ) {
       
    15 			url = $( '.nav-next a' ).attr( 'href' );
       
    16 
       
    17 		// Other key code.
       
    18 		} else {
       
    19 			return;
       
    20 		}
       
    21 
       
    22 		if ( url && ! $( 'textarea, input' ).is( ':focus' ) ) {
       
    23 			window.location = url;
       
    24 		}
       
    25 	} );
       
    26 } )( jQuery );