我想知道如何触发由 Ctrl+z
组成的事件 keyCode和由 Ctrl+Shift+z
组成的事件键码?
最佳答案
使用e.which
,它已经被jquery规范化了跨浏览器。
$(document).keydown(function(e){
if( e.which === 90 && e.ctrlKey && e.shiftKey ){
console.log('control + shift + z');
}
else if( e.which === 90 && e.ctrlKey ){
console.log('control + z');
}
});
关于javascript - jQuery 在所见即所得文本区域中触发 keyCode Ctrl+Shift+z 和 Ctrl+z,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7747536/