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

'action' on a keybinding prevents callbacks on subsequent keybindings with same 'combo' #195

Open
jwm opened this issue Dec 3, 2015 · 3 comments

Comments

@jwm
Copy link

jwm commented Dec 3, 2015

I define a hotkey in Controller A like so:

hotkeys.bindTo($scope).add({
    combo: 's',
    action: 'keydown',
    description: 'Do a thing',
    callback: function (event, hotkey) { /* profit! */ }
}

and a different hotkey in Controller B in the same way, except I omit the action:

hotkeys.bindTo($scope).add({
    combo: 's',
    description: 'Do a different thing',
    callback: function (event, hotkey) { /* profit in another way! */ }
}

I load (in a web browser) an Angular route that uses only Controller A, then click a link to view a different route that uses only Controller B.

The hotkey works fine in the Controller A route, but does not work in Controller B's. The cheat sheet shows the hotkey in both cases, with the correct description for the respective controller. Once I remove the action on the first hotkey, the second hotkey starts working.

This feels like something is wrong when scrubbing the scope's keybinding state. I don't have a proof of concept (this behavior is in a much larger app), but please let me know if I can help. I'm using Angular 1.3.15 (a little old, but we haven't had a chance to upgrade) and the latest version of angular-hotkeys.

@edenpessach
Copy link

+1 I believe I am experiencing the same thing using directives with bind logic (multiple directives = binds to the same keys) only binds and work for one of them.

@DioNNiS
Copy link

DioNNiS commented May 23, 2016

+1 Issue present event when events are in the same controller.

hotkeys.bindTo($scope)
    .add({
        combo: 's',
        action: 'keydown',
        description: 'Do a thing 1',
        callback: function (event, hotkey) { 
            console.log('s - keydown');
        }
    })
    .add({
        combo: 's',
        action: 'keyup',
        description: 'Do a thing 2',
        callback: function (event, hotkey) { 
            console.log('s - keyup');
        }
    });

I believe solution already provided in #193

@ntrpnr
Copy link

ntrpnr commented Sep 29, 2016

+1 experiencing the same problem with combo: 'shift' for action: 'keydown' and action: 'keyup'

Edit:

It actually works if I add the 'keyup' action before I add the 'keydown' action.

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

4 participants