我正在使用 HandsOnTable jquery 插件,并且正在尝试处理特定的组合键 ( Alt+ v) 快捷方式。但由于某种原因它不起作用,这是我的代码和jsfiddle:
$(document).ready(function () {
var isCtrl = false;
var isShift = false;
var isAlt = false;
// action on key up
$(document).keyup(function (e) {
if (e.which == 17) {
isCtrl = false;
}
if (e.which == 16) {
isShift = false;
}
if (e.which == 18) {
isAlt = false;
}
});
// action on key down
$(document).keydown(function (e) {
if (e.which == 17) {
isCtrl = true;
}
if (e.which == 16) {
isShift = true;
}
if (e.which == 18) {
isAlt = true;
}
if (e.which == 86 && isAlt) //alt+v
{
console.log("alt+v detected");
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
});
});