1

I downloaded the latest version of the jQuery plugin here. I noticed that it doesn't work if I bind it using keydown and pass in something with a character like 'ctrl+u'. I found that this piece of code seems to be preventing it.

    character = event.type === "keypress" && String.fromCharCode( event.which ).toLowerCase(),

namely this segment

event.type === "keypress"

This prevents the character from being true and then later binding the modif plus the character further down.

if ( character ) {
  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;
  }
}

I've seen people use this plugin on their site and they don't have the piece where event.type === "keypress" nor the if (character) piece. Is the hotkeys plugin designed to only accept characters with the keypress event? If so, the documentation doesn't say so.

griztown
  • 121
  • 3
  • 13

1 Answers1

0

The code === 'keypress' is no longer in master - if you re-test and it is still a problem send me a Fiddle and i'll take a look.

robbie613
  • 675
  • 1
  • 10
  • 8