Skip to content

Instantly share code, notes, and snippets.

@jakeauyeung
jakeauyeung / jekyll-keydown
Created April 24, 2014 02:10
用户浏览页面的时候可以使用键盘左右方向键导航到上一篇,下一篇
$(function(){
$(document).keydown(function(e) {
var url = false;
if (e.which == 37 || e.which == 72) { // Left arrow and J
{% if page.previous %}
url = '{{page.previous.url}}';
{% endif %}
} else if (e.which == 39 || e.which == 76) { // Right arrow and K
{% if page.next %}
url = '{{page.next.url}}';