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

Question/suggestion: Sequence consecutive? #112

Open chrjmeyer opened 8 years ago

chrjmeyer commented 8 years ago

We're using Keypress for lab experiments here at my department and it's tremendously helpful -- awesome job!

I was curious whether I'm missing an easy way to fire an event on a sequence combo being pressed consecutively? In the sequence combo below with q and w, the keyup event fires whenever I hold q and release w (which makes perfect sense). I was looking to fire an event whenever q is pressed and released first, then w is pressed and released after. In other words, when I type "q w". Using on_release, I get closer because I have to release both keys, but I can keep both of them down at the same time.

Maybe totally unclear -- happy to clarify.

consecseq_detect = function() {
    combos = [
      {
        keys: "q w",
        prevent_default: true,
        is_sequence: true,
        is_solitary: true,
        is_exclusive: true,
        on_release: function() {
            some_node.text("Correct consecutive sequence");
        }
      }
    ];
    return listener.register_many(combos);
  };
dmauro commented 8 years ago

Oh, hmmm, sounds like there might be a bug with on_keyup for sequence combos. Using on_keydown is probably your best bet, and I can look into getting on_keyup and release to work properly with sequences.

chrjmeyer commented 8 years ago

Ah, cool. Thanks! Meanwhile I've found a good workaround using on_release that works well in our setting.