Capturing the tab key using JavaScript in Firefox

后端 未结 2 1592
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 19:22

I use the following to restricts user to enter only some characters. When I press tab, the cursor does not point to next control (in Mozilla). But it works fine in IE.

相关标签:
2条回答
  • 2020-12-20 20:04

    Perhaps if you start with something like:

    if (e.keyCode === 9) { // TAB
        return true;
    }
    
    0 讨论(0)
  • 2020-12-20 20:17

    I would recommend trying e.keyCode instead of e.which. Here is a SO link that describes a good method of getting the key strike into a single variable regardless: jQuery Event Keypress: Which key was pressed?

    0 讨论(0)
提交回复
热议问题