]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/themes/twentyfifteen/js/keyboard-image-navigation.js
WordPress 4.7.2-scripts
[autoinstalls/wordpress.git] / wp-content / themes / twentyfifteen / js / keyboard-image-navigation.js
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 );