Skip to content

Instantly share code, notes, and snippets.

@bueltge
Created January 16, 2012 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bueltge/1619667 to your computer and use it in GitHub Desktop.
Save bueltge/1619667 to your computer and use it in GitHub Desktop.
Navigating with jQuery Keyboard Shortcuts
( 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