Angular 5 simulate keypress on input controls
问题 I'm trying to simulate tab key press when enter is pressed on input control.For that I use a directive: private el: ElementRef; @Input() onEnter: string; constructor(private _el: ElementRef, public renderer: Renderer) { this.el = this._el; } @HostListener('keydown', ['$event']) onKeyDown(e: any) { if ((e.which === 13 || e.keyCode === 13)) { e.preventDefault(); const event = new KeyboardEvent("keypress", { "key": "Tab" }); this.el.nativeElement.dispatchEvent(event); ............ code for enter