spaceshelter / orbitar

Experimental collective social/blogging platform with self-regulation.
MIT License
61 stars 24 forks source link

Editor hotKeys #302

Closed eyesplitter closed 1 year ago

eyesplitter commented 1 year ago

Added all hotkeys from #300

All hotkeys work with ctrl key for the people who love windows

Aivean commented 1 year ago

@eyesplitter Thank you for the contribution! The code looks good overall, however I found a bug when testing it locally. If a hotkey (say, CMD-b) is pressed when the form is not in focus it somehow gets "memorized" and triggered when the form gets focus and only the CMD key is pressed.

E.g. to reproduce:

  1. Open reply textarea
  2. Click outside it to make to lose focus
  3. Press CMD-b
  4. Click inside the textarea to make it gain focus
  5. Press CMD (just cmd)
  6. Observe that CMD-b event is fired

Demo: ezgif-1-abee070e90

Frankly I'm not sure what's going on, it maybe the bug in the react-hotkeys-hook library. Perhaps it would be easier to just extend the previous handleKeyDown approach?

eyesplitter commented 1 year ago

@Aivean I suppose that was a bug in the react-hotkeys-hook module. This behavior works only with the meta key. So I switched the handler from HotkeysEvent to KeyboardEvent and now it works as expected.