I have a component, where we have a button
There is a simple HostListener, which will display a notification on shortcut (ALT + Q)
@HostListener('window:keydown.alt.q', ['$event'])
displayNotification(event: KeyboardEvent) {
event.preventDefault();
this.messageService.add({
severity: 'success',
detail: 'Finished',
life: 5
});
}
Everything starts working only if I perform a click on the component, before that the notification does not appear
What is the cause and the appropriate solution?
Thanks!