Browse code

Add on-keyDown handler to prompt to trigger the relevant event

Joseph Weston authored on 10/12/2021 06:07:44
Showing 1 changed files
... ...
@@ -12,12 +12,14 @@
12 12
   (let [cmdline (re-frame/subscribe [::subs/cmdline])
13 13
         update-cmdline #(re-frame/dispatch-sync
14 14
                          [::events/update-cmdline (-> % .-target .-value)])
15
+        key-pressed #(re-frame/dispatch-sync [::events/prompt-keypress %])
15 16
         submit-cmd #(do (.preventDefault %)
16 17
                         (re-frame/dispatch [::events/submit-cmd (-> % .-target)]))]
17 18
     [:form {:class (styles/prompt-style)
18 19
             :on-submit submit-cmd}
19 20
      [:input {:value @cmdline
20 21
               :on-change update-cmdline
22
+              :on-keyDown key-pressed
21 23
               :type "text"}]]))
22 24
 
23 25
 (defn title []