wp/wp-content/themes/twentyfifteen/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 Fifteen keyboard support for image navigation.
       
     3  */
       
     4 
       
     5 ( function( $ ) {
       
     6 	$( document ).on( 'keydown.twentyfifteen', function( e ) {
       
     7 		var url = false;
       
     8 
       
     9 		// Left arrow key code.
       
    10 		if ( e.which === 37 ) {
       
    11 			url = $( '.nav-previous a' ).attr( 'href' );
       
    12 
       
    13 		// Right arrow key code.
       
    14 		} else if ( e.which === 39 ) {
       
    15 			url = $( '.nav-next a' ).attr( 'href' );
       
    16 		}
       
    17 
       
    18 		if ( url && ( ! $( 'textarea, input' ).is( ':focus' ) ) ) {
       
    19 			window.location = url;
       
    20 		}
       
    21 	} );
       
    22 } )( jQuery );