Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay #146

Open
tifDev opened this issue Dec 12, 2018 · 3 comments
Open

Delay #146

tifDev opened this issue Dec 12, 2018 · 3 comments

Comments

@tifDev
Copy link

tifDev commented Dec 12, 2018

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.

@dmauro
Copy link
Owner

dmauro commented Dec 12, 2018

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 dmauro closed this as completed Dec 12, 2018
@tifDev
Copy link
Author

tifDev commented Dec 13, 2018

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

@dmauro dmauro reopened this Dec 13, 2018
@ContraTrouble
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants