Adding window.event handler to typescript
To answer more clearly:
const controlDown = (event: KeyboardEvent) => {
console.log(event);
};
window.addEventListener('keydown', controlDown);
windows.addEventListener('keydown', (event: KeyboardEvent) =>{
// if you need event.code
});
windows.addEventListener('keydown', (event: Event) =>{
// event
});
This
window.addEventListener('keydown', keyDownListener, false)
window
is defined will all events in lib.d.ts
and this particular listener as
addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void;
or this, if you want to keep your original "style",
window.onkeydown = (ev: KeyboardEvent): any => {
//do something
}