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 #24

Closed
JAStanton opened this issue Apr 16, 2012 · 7 comments
Closed

Delay #24

JAStanton opened this issue Apr 16, 2012 · 7 comments
Labels
Question Issues that are questions about the library.

Comments

@JAStanton
Copy link

Is there a way to control the delay between keys pressed? E.g. if I have a keybinding of "g + i" I have to press G then I pretty fast, but if you look at gmails shortcuts you can press g then wait and then press i about > 1.5 seconds and it will still work. Thoughts?

@RobertWHurst
Copy link
Owner

Not in core. I'm trying to keep the library as simple and focused as possible. Things like temporal logic and control flow are out of the scope of this project. You can do this with setTimeout and a boolean.

@JAStanton
Copy link
Author

I would have to edit the core in order to add the setTimeout correct?

@RobertWHurst
Copy link
Owner

You shouldn't have to add this to KeyboardJS at all. I meant within your binding callback. Something like this.

var longKeyPress = false;
KeyboardJS.bind.key('i', function() {
    if(longKeyPress === 'g') {
        myHotKeyFunct();
        longKeyPress = false;
    } else {
        longKeyPress = 'i';
    }
});
KeyboardJS.bind.key('g', function() {
    if(longKeyPress === 'i') {
        myHotKeyFunct();
        longKeyPress = false;
    } else {
        longKeyPress = 'g';
    }
});

function myHotKeyFunct() {
    //Your logic here
}

@JAStanton
Copy link
Author

seems really hacky, I thought this would have been an issue while making the core, I will poke around a bit and see if I can make a more re-usable solution. Thanks for you tips though this helped

@RobertWHurst
Copy link
Owner

Well its not what I would put in a project of mine the way it is, its just an example to get you going. I wouldn't say its a hack.

I don't plan on adding this to KeyboardJS because the project is only concerned with giving developers the ability to bind to key combo events. How you want to attach your logic is up to you.

@JAStanton
Copy link
Author

Thanks so much for this tool it's awesome :)

@RobertWHurst
Copy link
Owner

Hey, no problem. I'm glad you like it. If you have any other ideas or questions feel free to post them here.

Cheers @JAStanton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Issues that are questions about the library.
Projects
None yet
Development

No branches or pull requests

2 participants