考虑以下代码:
[:input {:type "text"
:value (:text @app-state)
:on-change (fn [e]
(if (= 31 (.-keyCode e))
(println "ENTER")
(println "NOT ENTER")))}]
如何更改if
条件,以便可以区分回车键按下和普通按键?除target
之外,e
中的所有属性似乎都为null。
charCode
已经被废弃,推荐使用key
(请参考 https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)。 - BillRobertson42