首页 > 解决方案 > 使用 Mousetrap.js 聚焦输入字段-但输入字段也将热键粘贴为值?

问题描述

标签: javascriptreactjshotkeysinput-fieldmousetrap

解决方案


have you tried event.preventDefault() ?

Mousetrap.bind("alt+1", (e) => {
            e.preventDefault();
      this.focusTextInput(1);
    })

    Mousetrap.bind("alt+2", () => {
        e.preventDefault();
    this.focusTextInput(2)
    })

推荐阅读