Is there a way to disable the keyboard support for printable characters, mainly letters?
I want to suppress, that an option gets selected when typing any letter.
I tried something like this, but the problem is, that i have a directive bound to a parent component, that listens for key strokes and does stuff then.
const el = this.dropdown.nativeElement.querySelector('.ui-helper-hidden-accessible');
el.addEventListener(
'keydown',
(event: KeyboardEvent) => {
event.stopPropagation();
},
{ capture: true }
);
Also tried event.preventDefault() and event.returnValue = false which did not help.
To disable the selection of options in a dropdown via keyboard input, you can use the keydown event and prevent the default behavior when a printable character (letter) is pressed.
Create directive.
Declare directive in app.module.ts or any of your module
And in HTML add directive.
And edited Your Stackblitz