兼容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; }); };
1 楼
kenshu
2011-10-14
小哥,怎么调用 ?