How To Detect “Enter” Keypress in Reagent?

前端 未结 2 1077
孤城傲影
孤城傲影 2021-02-19 07:22

Given the following code:

  [:input {:type \"text\"
           :value (:text @app-state)
           :on-change (fn [e]
                        (if (= 31 (.-keyCo         


        
2条回答
  •  野性不改
    2021-02-19 07:39

    With key.

    [:input
     {:on-key-press
      (fn [e]
        (if (= (.-key e) "Enter")
          (.log js/console "Enter")
          (.log js/console "Not Enter")))}]
    

    Also of interest is :on-key-up and :on-key-down.

提交回复
热议问题