dmauro / Keypress

A keyboard input capturing utility in which any key can be a modifier key.
http://dmauro.github.io/Keypress/
Apache License 2.0
3.18k stars 313 forks source link

when registering "meta enter" and "enter" combos with { is_exclusive: true }, the "enter" on_keydown handler never gets called #60

Closed thasner closed 9 years ago

thasner commented 9 years ago

verified on Windows 7 chrome, IE11, and firefox

dmauro commented 9 years ago

Prevent default simply prevents the default browser behaviors from firing. If you want those two combos to be exclusive, set is_exclusive to true on both of those combos and when you press "meta enter" the "enter" combo will not trigger.

thasner commented 9 years ago

thanks so much!

thasner commented 9 years ago

Hey @dmauro ,

This still doesn't seem to be working properly for me. When I create on_keydown handlers for "enter" and "meta enter", both with is_exclusive set to true, only the "meta enter" handler works. The "enter" handler doesn't ever trigger (even when the enter key is pressed in isolation).

Is this the intended behavior?

roark commented 9 years ago

Hi @dmauro and @thasner,

I'm also experiencing the same issue in Chrome and FF on OS X. The following code fires the shift tab callback when shift tab is pressed. However, it doesn't fire the tab callback at all.

keypressListener.register_many([
      {
        "keys"              : "shift tab",
        "is_exclusive"      : true,
        "on_keydown"    : function() {
          console.log("You pressed shift + tab");
        }
      },
      {
        "keys"              : "tab",
        "is_exclusive"      : true,
        "on_keydown"    : function() {
          console.log("You pressed tab");
        }
      }
    ]);

If I set either or both is_exclusive to false then the behavior is that pressing tab calls the tab callback. Pressing shift tab calls both the tab and shift tab callbacks.

Is this a bug or possibly faulty combo configuration?

-- Side note: Enjoying the library, keep up the great work.