Skip to content

Instantly share code, notes, and snippets.

@karlding
Last active October 22, 2015 21:27
Show Gist options
  • Save karlding/d9b40f2af421191c7377 to your computer and use it in GitHub Desktop.
Save karlding/d9b40f2af421191c7377 to your computer and use it in GitHub Desktop.
Allows you to use arrow keys to navigate on XKCD
// ==UserScript==
// @name XKCD Arrow Keys
// @namespace http://github.com/karlding
// @version 0.1
// @description Allows you to use arrow keys to navigate on XKCD
// @author Karl Ding
// @match http*://xkcd.com/*
// @grant none
// ==/UserScript==
// look mom! no jQuery
window.addEventListener('keydown', function(e) {
var q = document.querySelector.bind(document);
switch (e.keyCode) {
case 74: case 37: // left, j
q("a[rel=prev]").click();
break;
case 76: case 39: // right, l
q("a[rel=next]").click();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment