【问题标题】:How to detect when user presses Esc in input field using Reagent如何使用试剂检测用户何时在输入字段中按下 Esc
【发布时间】:2016-03-27 11:22:47
【问题描述】:

我有一个输入字段

[:input {:type "text"}]

我需要检测用户在编辑该字段时何时按下 Esc 键。我该怎么做?

【问题讨论】:

    标签: clojurescript reagent


    【解决方案1】:

    为元素添加一个:on-key-up(或:on-key-down)处理程序:

    [:input {:type "text"
             :on-key-up #(when (= 27 (.-which %))
                           (do-something-here))}]
    

    【讨论】:

    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 2021-01-20
    • 2017-01-14
    • 1970-01-01
    相关资源
    最近更新 更多