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

keypres inbetween time control #6

Closed venkat330 closed 11 years ago

venkat330 commented 11 years ago

i dunno where to ask thats why raised this as an issue sorry..below is the seq i am planning to use

keypress.sequence_combo("backspace backspace", function() { // lives = 120; alert("You've pressed this bkspc."); }, true);

the issue i am facing is..

when i press backspace very contionus for 2 times it works as expected but when i delay the press it does not work,,

is there a way where we can control this intermediate keypress control

Regards Venkat.S

dmauro commented 11 years ago

There isn't right now, and you're right you should be able to control that. I'll update it as soon as I can.

venkat330 commented 11 years ago

thanks...waiting for the update

dmauro commented 11 years ago

Hey, I haven't updated the documentation yet, but I did push the implementation. There is now a global keypress.sequence_delay which is in milliseconds. The default is 800. This is how long Keypress will wait before deciding to stop considering sequential keypresses a sequence combo. You can set the delay to whatever you want, so if for instance you set it to 3000, your users would have 3 seconds between pressing the backspace key sequentially (without pressing any other keys in between) before it would give up and not consider them sequential. If you set keypress.sequence_delay to -1, it will give the user all the time they want (Keypress will always consider keys to be in sequence regardless of how long ago the last one was pressed).

I would be careful with the use of -1; it could very easily lead to a bad user experience. Users do not expect sequences to execute after a long delay.

In the future perhaps I can come up with a clever solution to allow for individual combos to set their sequence delays, but right now it would be extremely complex, so I'll just leave it as a global for now.

Please let me know if you run into any issues with the update!

Edit: Just in case it wasn't clear how to change the sequence delay, you would write in your code:

keypress.sequence_delay = 3000; // Or desired delay
dmauro commented 11 years ago

Gonna leave this open until I update the documentation.

dmauro commented 11 years ago

Documentation updated. Thank you.