Created
January 16, 2012 07:49
-
-
Save bueltge/1619667 to your computer and use it in GitHub Desktop.
Navigating with jQuery Keyboard Shortcuts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function ( $ ) { | |
$( document ).keydown( function( e ) { | |
var url = false; | |
if ( 37 == e.which ) { // Left arrow key code | |
url = $( '.prev a' ).attr( 'href' ); // set right class | |
} | |
else if ( 39 == e.which ) { // Right arrow key code | |
url = $( '.next a' ).attr( 'href' ); // set right class | |
} | |
if ( url ) { | |
window.location = url; | |
} | |
} ); | |
} )( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment