brtnshrdr / angular2-hotkeys

Keyboard shortcuts for Angular 2 apps
MIT License
203 stars 95 forks source link

Combo alt + number doesn't work #103

Closed dungvt closed 5 years ago

dungvt commented 5 years ago

Hello everybody, I have a hotkey that combined from 'alt' key and a number (from 0 - 5) key. But it doesn't work. My code here:

private filterHotkey = new Hotkey(['alt+1', 'alt+2', 'alt+3', 'alt+4', 'alt+5', 'alt+0'], function (event: KeyboardEvent): boolean {
    console.log(event.key);
}.bind(this));

I just changed 'alt' key to 'ctrl' key, it works normally. But I think that will be perfect if we can work with both 'alt' and 'ctrl'. Do you have any idea?

jnfaerch commented 5 years ago

This is also an issue when wanting the key combo to be two alphabet letters like g+d. Or having ? instead of f1 to open the shortcuts modal.

Is that a deliberate choice not to support this? (That's by the way exactly the same problem in ng-keyboard-shortcuts @omridevk )

omridevk commented 5 years ago

@jnfaerch

I wouldn't call it "deliberate" per se, it just a scenario we have yet decided to support, as it require some breaking changes in core code of the library (ng-keyboard-shortcuts), however. it is in my roadmap, and should be added in the future. As for this library, I cannot provide any further insight in regards to their decision.

omridevk commented 5 years ago

though it seems the base implementation here uses Mousetrap behind the scene, and I do not think Mousetrap supports key combination such as "a + b", it does support sequences though.

wittlock commented 5 years ago

Some webbrowsers will use some of those hotkeys for themselves, in which case they cannot be picked by a web application. I know firefox uses one control key and numbers to switch between tabs and in those cases it doesn't seem possible to use them.

Have you tried this in different browsers to see if it happens everywhere?

wittlock commented 5 years ago

Since no further feedback has been provided I'm closing this.