Ctrl + Key Combination – Simple Jquery Plugin

http://www.gmarwaha.com/blog/2009/06/16/ctrl-key-combination-simple-jquery-plugin/
$.ctrl = function (key, callback, args) {
   $(document).keydown(function (e) {
      if (!args)
         args = []; // IE barks when args is null
      if (e.keyCode == key.charCodeAt(0) && e.ctrlKey) {
         callback.apply(this, args);
         return true;
      }
   });
};
$.ctrl('V', function (s) {
   setTimeout(function () {}, 10);
}, function () {
   return true;
});

猜你喜欢

转载自snowelf.iteye.com/blog/2171461