omridevk / ng-keyboard-shortcuts

Dead Simple Keyboard Shortcuts Management for Angular

Home Page:https://ng-keyboard-shortcuts.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sequence with key modifiers

abitofdev opened this issue · comments

Describe the bug
Creating a sequence with modifier keys does not trigger the shortcut command.

To Reproduce
Steps to reproduce the behavior:

  1. Register a keyboard shortcut with a sequence containing a key modifier (CTRL, ALT, etc...)
    public shortcuts: ShortcutInput[] = [];

    constructor() {
        this.shortcuts.push(
            {
                label: 'Test',
                key: ['a b'],
                description: 'Testing no modifier',
                command: (event) => console.log(event.key),
                preventDefault: true
            },
            {
                label: 'Test',
                key: ['alt + a alt + b'],
                description: 'Testing modifier',
                command: (event) => console.log(event.key),
                preventDefault: true
            }
        );
    }
  1. The normal sequence will print the key combination to the console but the modifier sequence will not.

Expected behavior
The command should be invoked when entering the sequence with the correct key modifiers applied.

Versions

  • OS: Windows 10 64bit
  • Browser Chrome 76.0.3809.132 64bit
  • Package Version 8.0.0

Additional Context
The command will also not be invoked even if the sequence only contains one modifier key; for instance you cannot have a keyboard shortcut key: ['ctrl + a b']

commented

Thank you for reporting the issue.
Currently, sequences and combination do not work together in the same shortcut, it was never tested before.
I can add it to the roadmap, though it might need some redesign to support such use case, and I would like to hear more from the small community of users we have here if this feature is needed.

For now, I will add it as a known limitation but I will look into solving if possible without a major redesign to underlining architecture.
And thanks for reporting the issue, much appreciated I will do my best to address it, hopefully as part of the next release.
If I cannot fix, I will add a warning when adding an invalid shortcut until I can get this feature added.

commented

Still thinking about this. will have a more in depth look next weekend. sorry for the delay.

commented

will close it for now. will rethink this later on.

commented

@abitofdev
Thanks a lot for the PR! I am really grateful.
I will look into this in the future but can't handle it at the moment.