Last active
October 22, 2015 21:27
-
-
Save karlding/d9b40f2af421191c7377 to your computer and use it in GitHub Desktop.
Allows you to use arrow keys to navigate on XKCD
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
// ==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