function keyHandler(handleObj) {
    // Only care when a possible input has been specified
    if (typeof handleObj.data !== "string") {
      return;
    }

    var origHandler = handleObj.handler,
        keys = handleObj.data.toLowerCase().split(" ");

    handleObj.handler = function(event) {
      // Don't fire in text-accepting inputs that we didn't directly bind to
      if (this !== event.target && (/textarea|select/i.test(event.target.nodeName) ||
          jQuery.inArray(event.target.type, jQuery.hotkeys.textTypes) > -1)) {
        return;
      }

      // Keypress represents characters, not special keys
      var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[event.which],
          character = String.fromCharCode(event.which).toLowerCase(),
          modif = "", possible = {};

      // Check combinations (alt|ctrl|command|shift+anything)
      if (event.altKey && special !== "alt") {
        modif += "alt+";
      }

      if (event.ctrlKey && special !== "ctrl") {
        modif += "ctrl+";
      }

      if (event.metaKey && !event.ctrlKey && special !== "meta") {
        modif += "meta+";
      }

      if (event.shiftKey && special !== "shift") {
        modif += "shift+";
      }

      if (special) {
        possible[modif + special] = true;
      }
      else {
        possible[modif + character] = true;
        possible[modif + jQuery.hotkeys.shiftNums[character]] = true;

        // "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
        if (modif === "shift+") {
          possible[jQuery.hotkeys.shiftNums[character]] = true;
        }
      }

      // Record which keys are down
      var i, keyPressed;
      if (event.type === "keydown") {
        keyPressed = special || character;
        i = jQuery.inArray(keyPressed, jQuery.hotkeys.keysDown);
        if (i === undefined || i < 0) {
          jQuery.hotkeys.keysDown.push(keyPressed);
        }
      }
      // Release keys
      else if (event.type === "keyup") {
        keyPressed = special || character;
        i = jQuery.inArray(keyPressed, jQuery.hotkeys.keysDown);
        if (i !== undefined && i > -1) {
          jQuery.hotkeys.keysDown.splice(i, 1);
        }
        jQuery.hotkeys.lastKeysPressed.push(keyPressed);
        if (jQuery.hotkeys.lastKeysPressed.length > 5) {
          jQuery.hotkeys.lastKeysPressed.shift();
        }
      }

      for (i = 0, l = keys.length; i < l; i++) {
        if (possible[keys[i]]) {
          event.keyPressed = keys[i]; // note which key combination was actually pressed
          return origHandler.apply(this, arguments);
        }
      }
    };
  }
// Respond to bound keyboard events.
Respond to bound keyboard events.
Respond to bound keyboard events .
function keyHandler(handleObj) {
    if (typeof handleObj.data !== "string") {
      return;
    }
    var origHandler = handleObj.handler,
        keys = handleObj.data.toLowerCase().split(" ");
    handleObj.handler = function(event) {
      if (this !== event.target && (/textarea|select/i.test(event.target.nodeName) ||
          jQuery.inArray(event.target.type, jQuery.hotkeys.textTypes) > -1)) {
        return;
      }
      var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[event.which],
          character = String.fromCharCode(event.which).toLowerCase(),
          modif = "", possible = {};
      if (event.altKey && special !== "alt") {
        modif += "alt+";
      }
      if (event.ctrlKey && special !== "ctrl") {
        modif += "ctrl+";
      }
      if (event.metaKey && !event.ctrlKey && special !== "meta") {
        modif += "meta+";
      }
      if (event.shiftKey && special !== "shift") {
        modif += "shift+";
      }
      if (special) {
        possible[modif + special] = true;
      }
      else {
        possible[modif + character] = true;
        possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
        if (modif === "shift+") {
          possible[jQuery.hotkeys.shiftNums[character]] = true;
        }
      }
      var i, keyPressed;
      if (event.type === "keydown") {
        keyPressed = special || character;
        i = jQuery.inArray(keyPressed, jQuery.hotkeys.keysDown);
        if (i === undefined || i < 0) {
          jQuery.hotkeys.keysDown.push(keyPressed);
        }
      }
      else if (event.type === "keyup") {
        keyPressed = special || character;
        i = jQuery.inArray(keyPressed, jQuery.hotkeys.keysDown);
        if (i !== undefined && i > -1) {
          jQuery.hotkeys.keysDown.splice(i, 1);
        }
        jQuery.hotkeys.lastKeysPressed.push(keyPressed);
        if (jQuery.hotkeys.lastKeysPressed.length > 5) {
          jQuery.hotkeys.lastKeysPressed.shift();
        }
      }
      for (i = 0, l = keys.length; i < l; i++) {
        if (possible[keys[i]]) {
          event.keyPressed = keys[i]; 
          return origHandler.apply(this, arguments);
        }
      }
    };
  }
function keyHandler ( handleObj ) { if ( typeof handleObj . data !== "string" ) { return ; } var origHandler = handleObj . handler , keys = handleObj . data . toLowerCase ( ) . split ( " " ) ; handleObj . handler = function ( event ) { if ( this !== event . target && ( / textarea|select / i . test ( event . target . nodeName ) || jQuery . inArray ( event . target . type , jQuery . hotkeys . textTypes ) > - 1 ) ) { return ; } var special = event . type !== "keypress" && jQuery . hotkeys . specialKeys [ event . which ] , character = String . fromCharCode ( event . which ) . toLowerCase ( ) , modif = "" , possible = { } ; if ( event . altKey && special !== "alt" ) { modif += "alt+" ; } if ( event . ctrlKey && special !== "ctrl" ) { modif += "ctrl+" ; } if ( event . metaKey && ! event . ctrlKey && special !== "meta" ) { modif += "meta+" ; } if ( event . shiftKey && special !== "shift" ) { modif += "shift+" ; } if ( special ) { possible [ modif + special ] = true ; } else { possible [ modif + character ] = true ; possible [ modif + jQuery . hotkeys . shiftNums [ character ] ] = true ; if ( modif === "shift+" ) { possible [ jQuery . hotkeys . shiftNums [ character ] ] = true ; } } var i , keyPressed ; if ( event . type === "keydown" ) { keyPressed = special || character ; i = jQuery . inArray ( keyPressed , jQuery . hotkeys . keysDown ) ; if ( i === undefined || i < 0 ) { jQuery . hotkeys . keysDown . push ( keyPressed ) ; } } else if ( event . type === "keyup" ) { keyPressed = special || character ; i = jQuery . inArray ( keyPressed , jQuery . hotkeys . keysDown ) ; if ( i !== undefined && i > - 1 ) { jQuery . hotkeys . keysDown . splice ( i , 1 ) ; } jQuery . hotkeys . lastKeysPressed . push ( keyPressed ) ; if ( jQuery . hotkeys . lastKeysPressed . length > 5 ) { jQuery . hotkeys . lastKeysPressed . shift ( ) ; } } for ( i = 0 , l = keys . length ; i < l ; i ++ ) { if ( possible [ keys [ i ] ] ) { event . keyPressed = keys [ i ] ; return origHandler . apply ( this , arguments ) ; } } } ; }
Respond to bound keyboard events.
Respond to bound keyboard events .
// Only care when a possible input has been specified // Don't fire in text-accepting inputs that we didn't directly bind to // Keypress represents characters, not special keys // Check combinations (alt|ctrl|command|shift+anything) // "$" can be triggered as "Shift+4" or "Shift+$" or just "$" // Record which keys are down // Release keys // note which key combination was actually pressed