简体   繁体   中英

Press enter key then automatically press shift + tab

How to direct press Control + shift when i press enter key?

'activeKeyboard' : function($list){
  var that = this;

  $list.on('focus', function(){
    $(this).addClass('ms-focus');
  })
  .on('blur', function(){
    $(this).removeClass('ms-focus');
  })
  .on('keydown', function(e){
    switch (e.which) {
      case 40:
      case 38:
        e.preventDefault();
        e.stopPropagation();
        that.moveHighlight($(this), (e.which === 38) ? -1 : 1);
        return;
      case 13:
        e.preventDefault();
        e.stopPropagation();
        that.selectHighlighted($list);
        return;
      case 37:
      case 39:
        e.preventDefault();
        e.stopPropagation();
        that.switchList($list);
        return;
    }
  });
},

Well, your title mentions shift + tab, but then you say you want ctrl + shift... anyways, I will assume you want ctrl+shift, and you can easily modify that to work for shift+tab if you want.

You can try handling the keydown event, and check if the key pressed is ENTER, then simulate pressing CTRL + shift:

$(document).on("keydown", function(event) {
    if(event.keyCode == 13) { //(i.e. if ENTER is pressed)
         //simulate pressing CTRL + shift
         var e = jQuery.Event("keydown");
         e.which = 16;       // # key code of shift
         e.ctrlkey = true;     // control key pressed
         $(document).trigger(e);// trigger event on document
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM