omridevk / ng-keyboard-shortcuts

Dead Simple Keyboard Shortcuts Management for Angular
https://ng-keyboard-shortcuts.vercel.app/
147 stars 34 forks source link

Update documentation to help explain sequences clearer #141

Open abritabroad opened 2 years ago

abritabroad commented 2 years ago

I spent a few days digging through the code in order to figure out why my sequences were not working properly.

If you are trying to achieve the following scenario, the "g" command always wins.

[
    {
        key: ["g"],
        command: (output: ShortcutEventOutput) => console.log("g", output),
    },
    {
        key: ["g a"],
        command: (output: ShortcutEventOutput) => console.log("g a", output),
    }
]

If you add a trailing 'space' to to the first command's key, it will be treated as a sequence and the "g a" combination wins.

[
    {
        key: ["g "],   // <- Add trailing space here
        command: (output: ShortcutEventOutput) => console.log("g", output),
    },
    {
        key: ["g a"],
        command: (output: ShortcutEventOutput) => console.log("g a", output),
    }
]

Thanks!

omridevk commented 2 years ago

@abritabroad Are you referring to this? https://github.com/omridevk/ng-keyboard-shortcuts#important-note-1

abritabroad commented 2 years ago

Yes, there is no mention if needing a trailing space on the single key in order to get the double key's to work.

omridevk commented 2 years ago

I think that's more of a bug rather than a feature, i'll need to think about this. but the "g a" sequence suppose to win