ngneat/hotkeys

The alt.p shortcut does not work on MacOs

GitHubish opened this issue · 5 comments

I just added this library to manage more easily my different shortcuts in my application. But I notice that the shortcuts alt + p for example or alt + s do not work. While it works using hotkeysjs

//It's ok
hotkeys('alt+p', function(event, handler){
  alert('alt+p')
});

//It's not ok
this.hotkeys.addShortcut({ keys: 'alt.p' }).subscribe(e => console.warn('Hotkey', e));
this.hotkeys.addShortcut({ keys: 'alt.s' }).subscribe(e => console.warn('Hotkey', e));
 

Any ideas?
Thanks

The library delegates the work to Angular.

@NetanelBasal I think the problem is that it is the key property that is used. When I press Option (Alt) + p it considers that it is the "π" character that is entered in the key property. But in the code property it is KeyP.

Event bump - keycode.info

{
 "key": "π",
 "keyCode": 80,
 "which": 80,
 "code": "KeyP",
 "location": 0,
 "altKey": true,
 "ctrlKey": false,
 "metaKey": false,
 "shiftKey": false,
 "repeat": false
}

It might be useful to be able to determine if we want it to be based on the key or code property?

The code is the appropriate way to handle this. Can you check if it works with Angular events template syntax?

Hi @NetanelBasal, no indeed it does not work for example testing <input (keydown.alt.s)="onKeydown($event)">.

So this is the limits of what Angular offers. If I do on my keyboard Alt (option on mac) + s it does nothing. If I want my callback to be executed, I have to configure it like this: <input (keydown.alt.Ò)="onKeydown($event)"> because pressing these keys makes the character Ò. But this is certainly only the case for an Aserty keyboard and may even depend on the system language.

What do you think, so it is better that I subscribe with fromEvent no?

Yes