dispatching enter event

7 views
Skip to first unread message

Stéphane Ancelot

unread,
Apr 4, 2019, 2:19:07 AM4/4/19
to Angular and AngularJS discussion
Hi,

I am trying to implement ecel like navigation with a directive.

I am not able to propagate an enter event when keydown is pressed . 
What is the prefered way ?

@HostListener('keydown.arrowup', ['$event'])
@HostListener('keydown.arrowdown', ['$event'])
@HostListener('keydown.arrowright', ['$event'])
@HostListener('keydown.arrowleft', ['$event'])
onkeydown(event : KeyboardEvent)
{
let right = 39;
let down = 40;
//event.stopPropagation();
//event.preventDefault();
if (event.keyCode == 40)
{
let k = new KeyboardEvent('keydown',{"key":"Enter"});
this.el.nativeElement.dispatchEvent(k);
}
}


Regards,
S.Ancelot
Reply all
Reply to author
Forward
0 new messages