Skip to content

Instantly share code, notes, and snippets.

@pantaovay
Forked from pala/navigation.js
Created November 4, 2012 11:24
Show Gist options
  • Save pantaovay/4011474 to your computer and use it in GitHub Desktop.
Save pantaovay/4011474 to your computer and use it in GitHub Desktop.
jquery keyboard navigation
$(function(){
$(document).keydown(function(e) {
var url = false;
if (e.which == 37 || e.which == 74) { // Left arrow and J
{% if page.previous %}
url = '{{page.previous.url}}';
{% endif %}
}
else if (e.which == 39 || e.which == 75) { // Right arrow and K
{% if page.next %}
url = '{{page.next.url}}';
{% endif %}
}
if (url) {
window.location = url;
}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment