blob: 0e2d2c80d30a0aaa549a034e9f14998af4568cfe (
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.key == "j" || ev.key == "k") {
// alt j/k for moving up/down entries
var currentEntry = document.getElementsByClassName("entry-current")[0];
var sibling = currentEntry[ev.key == "j" ? "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.key == "g") {
// g for going back to top
document.getElementById("content-scroll").scrollTo({ top: 0, behavior: "smooth" });
}
});
})();
|