当我按下回车键时如何直接按Control + shift?
'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;
}
});
},
好吧,你的标题提到shift + tab,但是你说你想要ctrl + shift ...无论如何,我会假设你想要ctrl + shift,你可以轻松修改它以适用于shift + tab如果你想要的话。
您可以尝试处理keydown
事件,并检查按下的键是否为ENTER,然后模拟按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
}
});