Browse Source

fix chords cannot type issue

Weihua Lu 4 years ago
parent
commit
0de89fa43c
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/main/frontend/modules/shortcut/core.cljs

+ 8 - 3
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)