hotkeys-js icon indicating copy to clipboard operation
hotkeys-js copied to clipboard

isPressed is true on keyup

Open rakusan2 opened this issue 4 years ago • 2 comments

The event keyup is fired when a key is released (aka not pressed), so why is hotkeys.isPressed(key) still returning true for that key that fired that event?

rakusan2 avatar May 13 '20 20:05 rakusan2

@rakusan2 Are there any examples for me to test?

jaywcjlove avatar Jul 02 '20 15:07 jaywcjlove

Here is a simplified example

hotkeys('1', { keyup: true }, function(event, handler) {
            if (event.repeat) return
            const key = hotkeys.isPressed('1')

            console.log({ type: event.type, key })
        })

Result

{type: "keydown", key: true}
{type: "keyup", key: true}

What I expect

{type: "keydown", key: true}
{type: "keyup", key: false}

rakusan2 avatar Jul 06 '20 04:07 rakusan2