Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.