Last active
December 14, 2015 09:59
-
-
Save mattborn/5068555 to your computer and use it in GitHub Desktop.
dotjs page navigation via arrow keys on thecodinglove.com save as ~/.js/thecodinglove.com.js + make sure your using the dotjs chrome extension
This file contains 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
$(window).keydown(function(e){ | |
var next = parseInt(location.pathname.split('/')[2])+1 || 2; | |
var prev = parseInt(location.pathname.split('/')[2])-1; | |
if (e.which === 39) { | |
document.location.href = ('/page/'+next); | |
} else if (e.which === 37) { | |
document.location.href = ('/page/'+prev); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment