diff options
Diffstat (limited to 'yomichan-user/conf.d/shortcuts.js')
-rw-r--r-- | yomichan-user/conf.d/shortcuts.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/yomichan-user/conf.d/shortcuts.js b/yomichan-user/conf.d/shortcuts.js new file mode 100644 index 0000000..0e2d2c8 --- /dev/null +++ b/yomichan-user/conf.d/shortcuts.js @@ -0,0 +1,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" }); + } + }); +})(); |