JS监听键盘的组合按键

Mark 一下:

$(document).keydown(function (e) {
console.log(e);
var keyCode = e.keyCode || e.which || e.charCode;
var shiftKey = e.shiftKey;
if (shiftKey && keyCode == 68) {//shift+D
var leftbtnDisplay = $("#Leftbtn").css('display');
if (leftbtnDisplay=='none') {
$("#Rightbtn").click();
} else {
$("#Leftbtn").click();
}
}
else if (shiftKey && keyCode == 70) {//shift+F
var fullscreenDisplay = $("#fullscreen").css('display');
if (fullscreenDisplay == 'none') {
resetGridLocation();
} else {
changeSizeGrid();
}
}
else if (keyCode == 27 ) {//Esc
resetGridLocation();
}
});

posted @ 2016-08-21 14:23  shoupifeng  阅读(1838)  评论(0编辑  收藏  举报