Skip to content

Instantly share code, notes, and snippets.

@freetstar
Forked from pala/navigation.js
Created August 18, 2012 15:24
Show Gist options
  • Save freetstar/3387640 to your computer and use it in GitHub Desktop.
Save freetstar/3387640 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