mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Basic fix for shortcuts
This commit is contained in:
parent
19f1df3a02
commit
9550b127d9
3 changed files with 33 additions and 0 deletions
|
|
@ -1298,6 +1298,9 @@ class SvelteReviewer(Reviewer):
|
|||
self.bottom.web = self.web
|
||||
self.mw.bottomWeb.hide()
|
||||
|
||||
def _shortcutKeys(self) -> Sequence[tuple[str, Callable] | tuple[Qt.Key, Callable]]:
|
||||
return []
|
||||
|
||||
|
||||
# if the last element is a comment, then the RUN_STATE_MUTATION code
|
||||
# breaks due to the comment wrongly commenting out python code.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
$: if (iframe) {
|
||||
state.registerIFrame(iframe);
|
||||
state.registerShortcuts();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,35 @@ export class ReviewerState {
|
|||
iframe.addEventListener("load", this.onReady.bind(this));
|
||||
}
|
||||
|
||||
onKeyDown(e: KeyboardEvent) {
|
||||
switch (e.key) {
|
||||
case "1": {
|
||||
this.easeButtonPressed(0);
|
||||
break;
|
||||
}
|
||||
case "2": {
|
||||
this.easeButtonPressed(1);
|
||||
break;
|
||||
}
|
||||
case "3": {
|
||||
this.easeButtonPressed(2);
|
||||
break;
|
||||
}
|
||||
case "4": {
|
||||
this.easeButtonPressed(3);
|
||||
break;
|
||||
}
|
||||
case " ": {
|
||||
this.showAnswer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public registerShortcuts() {
|
||||
document.addEventListener("keydown", this.onKeyDown.bind(this));
|
||||
}
|
||||
|
||||
updateHtml(htmlString: string) {
|
||||
this.iframe?.contentWindow?.postMessage({ type: "html", value: htmlString }, "*");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue