diff --git a/js/keyboard-navigation.js b/js/keyboard-navigation.js new file mode 100644 index 00000000..80a22b1d --- /dev/null +++ b/js/keyboard-navigation.js @@ -0,0 +1,14 @@ +jQuery( document ).ready( function( $ ) { + $( document ).keydown( function( e ) { + var url = false; + if ( e.which == 37 ) { // Left arrow key code + url = $( '.previous-image a' ).attr( 'href' ); + } + else if ( e.which == 39 ) { // Right arrow key code + url = $( '.next-image a' ).attr( 'href' ); + } + if ( url && ( !$( 'textarea, input' ).is( ':focus' ) ) ) { + window.location = url; + } + } ); +} ); \ No newline at end of file