JS 捕获 input 中 键盘按键 的相应处理事件是很简单的,google搜索一下很容易找到处理方式,请看如下一种简单的处理方式:

HTML代码:

        <div>
            <input type="text" id="myinput" />
        </div>


JavaScript 方法:

    $("#myinput").on("keydown", function (e) {
        if (e.keyCode == 13) {
            //to-do when click Enter Key
        }
    });

 

下面列举其他常用按键的所对应的KeyCode:

JS 捕获 input 中 键盘按键

 

用Jquery绑定其他按键事件的方式,请看如下链接:http://api.jquery.com/category/events/keyboard-events/ 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-11-27
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
相关资源
相似解决方案