I have the following keydown
event function:
@HostListener('keydown', ['$event'])
myFunc(e: KeyboardEvent) {
if (e.which === 13 || e.which === 32) {
e.preventDefault();
foo();
}
}
If I remove the e.preventDefault(), the function is working correctly only in Chrome. And only Enter key is not working on the IE11 and Firefox. But when I add preventDefault(), it works on all the browsers correctly.
My question is, what exact behavior preventDefault() is blocking here in Firefox and IE11? Could anyone help me out with an explanation.
Thank you.