Issue
Normally when I wanted to catch an event on a page in js:
window.onkeydown = function (event) {
//Do something here
}
I cannot seem to figure out (or Google) how to do this in typescript. For the setup I am working in, there is a ts
file for the page, and a ts
file for the class that it is loading.
Solution
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
}
Answered By - Bruno Grieder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.