【问题标题】:onKeydown event in react-selectreact-select 中的 onKeydown 事件
【发布时间】:2018-09-25 06:49:39
【问题描述】:

我正在使用 react-select vserion 2 组件。我希望能够在有人按下退格键时触发 OnKeyDown 事件。

有人知道怎么做吗?

【问题讨论】:

标签: reactjs onkeydown react-select


【解决方案1】:

react-select 提供了一个 prop onKeyDown,您可以将其用作以下示例:

 const onKeyDown = e => {
    // catch the code of the key pressed
    if (e.keyCode === 8) {
      // do your stuff
    }
  };

在这个函数中你可以捕捉到按下的键的keyCode

这里是live example

【讨论】:

    猜你喜欢
    • 2017-09-16
    • 2022-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-14
    • 2018-04-27
    • 1970-01-01
    相关资源
    最近更新 更多