Alanaktion / phproject

A high performance full-featured project management system
https://www.phproject.org
GNU General Public License v3.0
388 stars 106 forks source link

Keyboard shortcuts incorrectly trigger when modifier is released early #342

Closed Alanaktion closed 6 years ago

Alanaktion commented 6 years ago

The modifier is not explicitly checked for when matching some of the keyboard shortcuts, meaning e.g. pressing C to copy text will also trigger the C shortcut, focusing the comment textarea. This can be resolved by always checking the status of all modifier keys regardless of whether they're required to be held for the combination.

Alanaktion commented 6 years ago

Actually it looks like it is being accounted for as far as I understand the keyup event, so there might be something more complicated going on. I'd welcome any outside knowledge on this one!

aaroneiche commented 6 years ago

I can't replicate this -  C copies, and C focuses to the comment text box. Can you provide steps to replicate? (I am on v18.02.19)

Alanaktion commented 6 years ago

This seems to happen specifically if the non-modifier key is released after the modifier key, and actually affects all browsers and operating systems. I must have different muscle memory on Mac.

For example to reproduce the C issue:

  1. Press and hold
  2. Press and hold C
  3. Release
  4. Release C

That will cause both the native copy operation and the JS-based hotkey event. I'm not sure exactly how we'd want to account for something like that, but it should be doable by storing the modifier state on keydown or something like that.