blob: 8b6aafc58c2cf86fb8e30e23f6510764eb3a5c10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
(() => {
window.addEventListener("keydown", ev => {
if (ev.altKey != true) return;
if (ev.code == "KeyJ" || ev.code == "KeyK") {
// alt j/k for moving up/down entries
var currentEntry = document.getElementsByClassName("entry-current")[0];
var sibling = currentEntry[ev.code == "KeyJ" ? "nextSibling" : "previousSibling"];
if (sibling == null) return;
currentEntry.classList.remove("entry-current");
sibling.classList.add("entry-current");
sibling.scrollIntoView({ behavior: "smooth", block: "center" });
}
else if (ev.code == "KeyG") {
// g for going back to top
document.getElementById("content-scroll").scrollTo({ top: 0, behavior: "smooth" });
}
});
})();
|