From a7567f510dc2414f49d657201c3a7bf3c83bbe1a Mon Sep 17 00:00:00 2001 From: Tuomas Airaksinen Date: Thu, 12 Oct 2023 18:25:27 +0300 Subject: [PATCH] Implement space toggles speak (#2622) --- app/bibleview-js/src/composables/keyboard.ts | 3 ++- .../android/view/activity/page/BibleJavascriptInterface.kt | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/bibleview-js/src/composables/keyboard.ts b/app/bibleview-js/src/composables/keyboard.ts index 05aa5afe77..f0592e859d 100644 --- a/app/bibleview-js/src/composables/keyboard.ts +++ b/app/bibleview-js/src/composables/keyboard.ts @@ -22,7 +22,7 @@ import {computed, ComputedRef, ref, watch} from "vue"; const altKeys: Set = new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "KeyW", "KeyM", "KeyO", "KeyG"]); const ctrlKeys: Set = new Set(["KeyC"]); -const keys: Set = new Set(["ArrowUp", "ArrowDown"]); +const keys: Set = new Set(["ArrowUp", "ArrowDown", "Space"]); const handleJsSide: Set = new Set(["ArrowUp", "ArrowDown"]); export function useKeyboard( @@ -54,6 +54,7 @@ export function useKeyboard( doScrolling(window.scrollY - lineHeight.value, 50); } } else { + if(key === "Space" && isEditing.value) return; onKeyDown(key); } e.preventDefault(); diff --git a/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt b/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt index 83c7adbfef..94cb605449 100644 --- a/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt +++ b/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt @@ -606,6 +606,11 @@ class BibleJavascriptInterface( "AltKeyO" -> mainBibleActivity.showOptionsMenu() "AltKeyG" -> bibleView.window.pageManager.currentPage.startKeyChooser(mainBibleActivity) "CtrlKeyC" -> bibleView.copySelectionToClipboard() + "Space" -> { + if(!mainBibleActivity.speakControl.isStopped) { + mainBibleActivity.speakControl.toggleSpeak(true) + } + } } } }