Jquery ctrl+key快捷键实现 How to create Ctrl+Key shortcuts in Javascript

邓业
2023-12-01
兼容ie6-ie8/Chrome/Firefox

/**
* Ctrl+Key shortcuts
* @param {string} key,etc:'A'
* @param {function} callback:event callback
* @param {array} args:callback's args
*/
$.ctrl = function(key, callback, args){
var isCtrl = false;
$(document).keydown(function(e){
if (e.which === 17)
isCtrl = true;
if (e.which === key.charCodeAt(0) && isCtrl === true) {
callback.apply(this, args);
return false;
}
}).keyup(function(e){
if (e.which === 17)
isCtrl = false;
});
};
 类似资料: