Is there any way to disable the keyboard keys using Angular 2+(Typescript). I want to disable all keys in keyboard. But, the keys should be work on HTML input fields.
Import this HostListener
import { HostListener } from '@angular/core';
Then, put this code to prevent keyboard keys..
@HostListener('document:keydown', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
console.log(event);
event.returnValue = false;
event.preventDefault();
//or
//do something
}