diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-30 19:07:24 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-30 19:07:24 +0100 |
commit | a29b452b89b2f83f0785f7e05ef5de0e60645b5a (patch) | |
tree | 4c867df855826dac2aeb7441465e52e39580e191 | |
parent | f1fa7f0c181ab96a42c8bd7bbab4c8270fe31acf (diff) |
clean up keyboard shortcuts + add shortcut for copying sentence
-rw-r--r-- | yomichan-user/conf.d/sentence-export.js | 7 | ||||
-rw-r--r-- | yomichan-user/conf.d/shortcuts.js | 6 | ||||
-rw-r--r-- | yomichan-user/conf.d/word-export.js | 3 | ||||
-rw-r--r-- | yomichan-user/makefile | 5 |
4 files changed, 14 insertions, 7 deletions
diff --git a/yomichan-user/conf.d/sentence-export.js b/yomichan-user/conf.d/sentence-export.js index f187b64..bf952dd 100644 --- a/yomichan-user/conf.d/sentence-export.js +++ b/yomichan-user/conf.d/sentence-export.js @@ -50,6 +50,13 @@ function patchSearchBar() { patchSearchBar(); document.body.classList.add("sentence-export-patched"); + + window.addEventListener("keydown", ev => { + if (ev.code != "KeyC") return; + if (ev.shiftKey != true) return; + if (ev.altKey != true) return; + document.getElementById("anki-sentence-export-button").click(); + }); })(); } diff --git a/yomichan-user/conf.d/shortcuts.js b/yomichan-user/conf.d/shortcuts.js index 0e2d2c8..8b6aafc 100644 --- a/yomichan-user/conf.d/shortcuts.js +++ b/yomichan-user/conf.d/shortcuts.js @@ -1,16 +1,16 @@ (() => { window.addEventListener("keydown", ev => { if (ev.altKey != true) return; - if (ev.key == "j" || ev.key == "k") { + 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.key == "j" ? "nextSibling" : "previousSibling"]; + 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.key == "g") { + else if (ev.code == "KeyG") { // g for going back to top document.getElementById("content-scroll").scrollTo({ top: 0, behavior: "smooth" }); } diff --git a/yomichan-user/conf.d/word-export.js b/yomichan-user/conf.d/word-export.js index 8f512d6..7950dd7 100644 --- a/yomichan-user/conf.d/word-export.js +++ b/yomichan-user/conf.d/word-export.js @@ -72,7 +72,8 @@ function addWordCopyButtons() { addWordCopyButtons(); }); window.addEventListener("keydown", ev => { - if (ev.key != "c") return; + if (ev.code != "KeyC") return; + if (ev.shiftKey != false) return; if (ev.altKey != true) return; exportWord(document.getElementsByClassName("entry-current")[0]); }); diff --git a/yomichan-user/makefile b/yomichan-user/makefile index 68a103b..c4cf026 100644 --- a/yomichan-user/makefile +++ b/yomichan-user/makefile @@ -1,4 +1,4 @@ -.PHONY: clean all +.PHONY: clean all FORCE M4FLAGS += -I./assets/ @@ -40,8 +40,7 @@ user.js: user.css: cat $^ > $@ -header.txt: header.txt.m4 -header.txt: ../.git/HEAD +header.txt: header.txt.m4 FORCE yomichan-user.js: header.txt user.min.js cat $^ > $@ |