what is the key code for shift+tab?

后端 未结 4 931
孤街浪徒
孤街浪徒 2020-12-04 22:50

I am working on key mapping. The problem is that when I press the TAB button down it navigates to the next input field.

TAB has key of 9 and
DO

相关标签:
4条回答
  • 2020-12-04 23:28

    in my GWT case

    if(event.isShiftKeyDown() && event.getNativeKeyCode() == KeyCodes.KEY_TAB){
        //Do Something
    }
    
    0 讨论(0)
  • 2020-12-04 23:45

    you can use the event.shiftKey property for that: http://www.java2s.com/Code/JavaScript/Event/Shiftkeypressed.htm

    0 讨论(0)
  • 2020-12-04 23:50

    There's no "keycode", it's a separate property on the event object, like this:

    if(event.shiftKey && event.keyCode == 9) { 
      //shift was down when tab was pressed
    }
    
    0 讨论(0)
  • 2020-12-04 23:50

    e.keyCode has been deprecated for sometime. Use "e.key" KeyboardEvent.key instead.

    Usage:

    e.shiftKey && e.key === 'Tab'
    

    Example:

    function clicked(e) {
        if (e.shiftKey && e.key === 'Tab') {
            // Do whatever, like e.target.previousElementSibling.focus();
        }
    }
    
    0 讨论(0)
提交回复
热议问题