我一直在使用来自jeresig 的 hotkey 的jquery hotkeys 插件。当文档处于焦点时,快捷方式工作正常,但当焦点在输入字段中时,快捷方式不起作用。我已经使用$(document)
或$(document).find('input')
用于绑定。但这些也不起作用。
我使用以下代码制作快捷方式:
$(document).ready(function(){
shortcutsInit();
});
function shortcutsInit(){
$(document).bind('keydown', "shift+f2", function() {
window.location.replace("/list");
return false;
});
$(document).bind('keydown', "f3", function() {
if($('#searchholder').length){
$('#searchholder').focus();
}
console.log('f3 pressed');
return false;
});
}