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

Sequence Timing #68

Closed ronnyek closed 9 years ago

ronnyek commented 9 years ago

I've created a sequence that when I hit " " (tick tick) I want it to trigger an action.

I can get it to trigger, and it pops up an alert as expected, but then the very next tick I type into say a text field, its popping up the alert again.

My question is, is there any time threshold or setting for that per sequence so that I can say if I typed two ticks in a row, within 500ms, treat it as a sequence, otherwise just let the characters through?

The other thing to note, even though it was triggering the desired action, it was not actually blocking the keypresses in those events (ticks ended up in the textbox)

dmauro commented 9 years ago

So the last bit is easy: you have to manually set prevent_default to true to prevent default browser behavior for keys involved in a combo.

The default sequence delay is 800ms (I should make that easy for users to tweak) and as long as you hit the next key in a sequence before that 800ms is up, it will consider that input as working towards any possible combos that include them (and will prevent the default browser behaviors if that sequence combo is set to prevent default).

The first part of your issue is the trickiest, but it sounds like there is a bug in the code that is matching inputs to sequences and it keeps matching the double tick combo every time you hit the sequence instead of every other time (if I'm reading that right). I'll have to look into that.

dmauro commented 9 years ago

Just confirmed there is definitely a bug when you try to do a sequence of two of the same characters. Thank you!

dmauro commented 9 years ago

https://github.com/dmauro/Keypress/commit/326c417428d00fc5582df520b07f2528b7ad103b