Skip to content

Instantly share code, notes, and snippets.

@torrottum
Last active November 1, 2017 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torrottum/e9606db9c89323be7bf7360d52d76f13 to your computer and use it in GitHub Desktop.
Save torrottum/e9606db9c89323be7bf7360d52d76f13 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name AI: Foundations of Computational Agents key navigation
// @namespace https://torrottum.no
// @version 0.1
// @description Allows you to use arrow keys or vi-style (hkl) keys to navigate the Artificial Intelligence: Foundations of Computational Agents book
// @author Tor Røttum
// @match http://artint.info/2e/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.onkeydown = function(event) {
var prev = document.querySelector('.prev');
var up = document.querySelector('.up');
var next = document.querySelector('.next');
var key = event.key;
if ((key === 'ArrowLeft' || key === 'h') && prev) {
left.parentNode.click();
}
if ((key === 'ArrowUp' || key === 'k') && up) {
up.parentNode.click();
}
if ((key === 'ArrowRight' || key === 'l') && next) {
next.parentNode.click();
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment