Keypress icon indicating copy to clipboard operation
Keypress copied to clipboard

Question/suggestion: Sequence consecutive?

Open chrjmeyer opened this issue 8 years ago • 2 comments

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);
  };

chrjmeyer avatar Apr 02 '16 23:04 chrjmeyer

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.

dmauro avatar Apr 03 '16 16:04 dmauro

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

chrjmeyer avatar Apr 03 '16 19:04 chrjmeyer