时间:2021-07-01 10:21:17 帮助过:4人阅读
1)tabindex:
就是利用tab来轻松的控制页面中的链接和表单元素
它的用法很简单:obj.tabindex = tabindex; 这个tabindex 的值,按照w3c 的规定可以从0开始 一直到32767
2) js 设置组合快捷键
本质就是获得你要设置的这个键的keyCode 的值,如果要加ctrl,alt,shift,那么就添加一个ctrlkey,altKey,shiftKey来判断下,所以关键在于keycode的值
(1) 设置 ctrl +enter 提交
if (e.ctrlKey && e.keyCode == 13){
return submit();
}
(2) 设置 Alt+ 方向键 ←
if (e.altKey&& e.keyCode == 37){
return submit();
}
(3) 设置 shift+F10
if (e.shiftKey&& e.keyCode == 37){
return submit();
}
4) 设置en
ter 提交
if (e.keyCode == 13){
return submit();
}
这里附加一些常见的快捷键:
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space
keycode 33 = Prior
keycode 34 = Next
keycode 35 = End
keycode 36 = Home
keycode 37 = Left
keycode 38 = Up
keycode 39 = Right
keycode 40 = Down
keycode 41 = Select
keycode 42 = Print
keycode 43 = Execute
keycode 45 = Insert
keycode 46 = Delete
keycode 47 = Help
注意:浏览器的兼容性问题