aboutsummaryrefslogtreecommitdiff
path: root/yomichan-user/conf.d/shortcuts.js
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-01-30 16:56:55 +0100
committerlonkaars <loek@pipeframe.xyz>2023-01-30 16:56:55 +0100
commit7722306155088966bd2e09a0a7ba910ca9141fd1 (patch)
tree69c990ec8cb645e383186c6f401140758bd82227 /yomichan-user/conf.d/shortcuts.js
parentea06526ea33df1ae5b38065a87c72af1614ace22 (diff)
added shortcuts, fixed duplicate buttons and updated readme3.2.0
Diffstat (limited to 'yomichan-user/conf.d/shortcuts.js')
-rw-r--r--yomichan-user/conf.d/shortcuts.js18
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" });
+ }
+ });
+})();