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

on_keydown doesn't fire up if key is in 2 combos #72

Open Canardlaquay opened 9 years ago

Canardlaquay commented 9 years ago

Sorry for the title, don't know how to resume this in a single phrase.

I've got this code: (just modified a bit from the site's example)

var my_scope = this;
var my_combos = listener.register_many([
    {
        "keys"          : "shift s",
        "is_exclusive"  : true,
        "on_keydown"    : function() {
            console.log("You pressed shift and s together.");
        },
        "on_keyup"      : function(e) {
            console.log("And now you've released one of the keys.");
        },
        "this"          : my_scope
    },
    {
        "keys"          : "s",
        "is_exclusive"  : true,
        "on_keydown"    : function() {
            console.log("You pressed s.");
        },
        "on_keyup"      : function(event) {
          console.log("You released s.");
        },
        "this"          : my_scope
    }
]);

I use the is_exclusive feature as the site describes, everything works fine, except that the on_keydown for the single key (here, "s") doesn't fire up.

dmauro commented 9 years ago

See comments on https://github.com/dmauro/Keypress/pull/73

franciscop commented 9 years ago

This really kills the experience with any kind of "moving around" key press. For instance, when I want to perform some movement, I want to be able to trigger:

The best would be if the third was a consequence of pressing W and D at the same time and didn't require a separate action, but it doesn't seem to be the case.

dmauro commented 9 years ago

Determining if two keys are pressed "at the same time" is a can of worms I don't want to deal with because it means introducing arbitrary buffer times that would make anything relying on Keypress feel laggy.