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

[Bug] Pressing both Shift keys and then releasing one, returns shiftKey:false #201

Closed aizaku closed 3 years ago

aizaku commented 5 years ago

Steps to reproduce:

  1. Hold down both left and right [Shift] keys
  2. Press any other key (for ex. [c])
  3. Release one of the [Shift] keys
  4. Press any other key again (for ex. [c])

Expected result: shiftKey: true, since one is still being held down Actual result:

{
  shiftKey: false,
  altKey: false,
  ctrlKey: false,
  metaKey: false,
  keychar: 67,
  keycode: 0,
  rawcode: 67,
  type: 'keypress'
}

node v10.16.3 electron v6.0.12

Also a question: is there a way to differentiate between left and right modifier keys? Would be helpful in some cases. If not, is it planned in future release?

p.s. just noticed this while doing some testing while I wait for electron 7 support ;)

ackvf commented 4 years ago

If the user presses shift first, there is a brief moment when you can capture the keyCode of the shift key which is different for left and right shift, you could then memorise it.

Also it's rather interesting how this library handles keys, for example npm keypress does that completely differently and will continue to emit capital letter when one of shifts gets depressed.

ash0x0 commented 3 years ago

Closing as apparently answered.