From 0de89fa43c6692f8bd18e25cf0a0ff2e46b173c4 Mon Sep 17 00:00:00 2001 From: Weihua Lu Date: Sat, 10 Apr 2021 01:02:18 +0800 Subject: [PATCH] fix chords cannot type issue --- src/main/frontend/modules/shortcut/core.cljs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/frontend/modules/shortcut/core.cljs b/src/main/frontend/modules/shortcut/core.cljs index 7ac6b7d44..28ae24ca3 100644 --- a/src/main/frontend/modules/shortcut/core.cljs +++ b/src/main/frontend/modules/shortcut/core.cljs @@ -7,7 +7,8 @@ [goog.events :as events] [goog.ui.KeyboardShortcutHandler.EventType :as EventType] [lambdaisland.glogi :as log]) - (:import [goog.ui KeyboardShortcutHandler])) + (:import [goog.ui KeyboardShortcutHandler] + [goog.events KeyCodes])) (def installed (atom [])) (def binding-profile (atom [binding/default binding/custom])) @@ -27,11 +28,15 @@ shortcut) (mapv mod-key)))) +(def global-keys #js + [KeyCodes/ENTER KeyCodes/TAB + KeyCodes/UP KeyCodes/LEFT KeyCodes/DOWN KeyCodes/RIGHT]) + (defn install-shortcut! [shortcut-map] (let [handler (new KeyboardShortcutHandler js/window)] - ;; default is false, set it to true to deal with arrow keys, etc - (.setAllShortcutsAreGlobal handler true) + ;; set arrows enter, tab to global + (.setGlobalKeys handler global-keys) ;; default is true, set it to false here (.setAlwaysPreventDefault handler false)