How to detect a pressed button using setInterval and without any event in javascript?

12 views Asked by At

I want to get a pressed mouse or keyboard button from global object window or document when it's listening in setInterval.

setInterval(function () {

    window.mouse.button. ...;
    window.keyboard.button. ...;

    // or maybe

    document.mouse.button. ...;
    document.keyboard.button. ...;

}, 1);

It would be kind of my own self-made event.

How to detect a pressed button using setInterval and without any event in javascript?

setInterval(function () {

    window.mouse.button. ...;
    window.keyboard.button. ...;

    // or maybe

    document.mouse.button. ...;
    document.keyboard.button. ...;

}, 1);
0

There are 0 answers