Skip to content

Instantly share code, notes, and snippets.

@sheharyarn
Created April 21, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheharyarn/6a8c66e05a1a5b0f2dbc to your computer and use it in GitHub Desktop.
Save sheharyarn/6a8c66e05a1a5b0f2dbc to your computer and use it in GitHub Desktop.
jQuery use Arrow Keys to go to next/previous (comic) page
(function($) {
function goToComic(position) {
comicLink = $('link[rel="' + position + '"]').attr('href');
if (comicLink)
window.location.href = comicLink;
}
$(document).keydown(function(e) {
e.preventDefault();
switch(e.which) {
case 37:
// Left Key Pressed
goToComic('prev');
break;
case 39:
// Right Key Pressed
goToComic('next');
break;
default:
return;
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment