wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.2k stars 291 forks source link

iohook keypress remembers old key event #220

Closed pgupt closed 4 years ago

pgupt commented 4 years ago

In my electron-vue app, I am registering iohook for detecting keypress event. For the first time I get the right event I am looking for. (e.g. I am looking for alt + space and shift+space)

After this I call iohook.stop() thinking it would stop and reset the iohook.

But the second time I press alt + space, I get true for shift also even though I had not pressed it. I think iohook does not reset itself when stopped.

Expected Behavior

iohook should reset events when stop() is called

Your Environment

ape-casear commented 4 years ago

You need to iohook.off('event') manually

pgupt commented 4 years ago

@ape-casear it still remembers old event. In my case, it remembers alt key is pressed.

pgupt commented 4 years ago

I found out the issue. I am new to Vue and do not have complete knowledge of it.

So I was starting the iohook in actions. The advantage or disadvantage with actions in Vue is that it will called only once. So my iohook.start wasn't being called again and that is why keypress persisted.