Keypress icon indicating copy to clipboard operation
Keypress copied to clipboard

Delay

Open tifDev opened this issue 7 years ago • 3 comments

Is it possible to increase the delay time of a combination? I have longer combinations on my web app like 'a r c g' or 'a r c g k' and they take a bit time to think & press.

tifDev avatar Dec 12 '18 19:12 tifDev

Yup! Check out https://github.com/dmauro/Keypress/blob/development/keypress.coffee#L95, it's a little hidden but sequence_delay is a public property on the keypress.Listener which you can set (it's milliseconds).

dmauro avatar Dec 12 '18 20:12 dmauro

It has no effect... i changed to 2000 miliseconds but i still need to type very fast for the combo to get count. See my small fiddle: https://jsfiddle.net/ombjs132/5/

The code:


var listener = new window.keypress.Listener();

listener.sequence_delay = 2000;


var my_scope = this;
var my_combos = listener.register_many([
    {
        "keys"          : "r c g",
        "is_exclusive"  : true,
        "on_keyup"      : function(event) {
        console.log("You pressed r c g.");
            return true
        }
    },
    {
        "keys"          : "r c",
        "is_exclusive"  : true,
        "on_keyup"      : function(event) {
        console.log("You pressed r c.");
            return true
        }
    }
]);

tifDev avatar Dec 13 '18 15:12 tifDev

I don't know what changed, but I found sequence_delay in the g property of the listener, so my code (which works) looks like this:

if ('g' in keyListener && 'sequence_delay' in (keyListener as any)!.g) {
  (keyListener as any).g.sequence_delay = MaxSequenceTimeoutInMillis;
} else  if ('sequence_delay' in keyListener) {
  // this one is just in case the "global" property starts working some day
  (keyListener as any).sequence_delay = MaxSequenceTimeoutInMillis;
}

ContraTrouble avatar Dec 26 '22 19:12 ContraTrouble