roam-toolkit icon indicating copy to clipboard operation
roam-toolkit copied to clipboard

Consider hotkey libraries other than react-hotkeys

Open tntmarket opened this issue 4 years ago • 5 comments

roam-toolkit currently uses https://github.com/greena13/react-hotkeys to listen to keys.

It works well for the most part, but various bugs made vim style bindings harder to implement:

  • https://github.com/greena13/react-hotkeys/issues/234
  • https://github.com/greena13/react-hotkeys/issues/249
  • https://github.com/greena13/react-hotkeys/issues/229
  • https://github.com/greena13/react-hotkeys/issues/255

Also, react-hotkeys is no longer actively maintained.

This deliverable here would be evaluating other options, and seeing how much there is to be gained by switching.

Other options:

https://github.com/ccampbell/mousetrap

  • Seems moderately/low activity? Decent number of old open issues

https://github.com/jaywcjlove/hotkeys

  • The API doesn't have key sequences built it
  • I personally find the DX of react-hotkeys a little more convenient.

Help maintain react-hotkeys

Roll our own hotkey library

tntmarket avatar May 22 '20 08:05 tntmarket

I've used mousetrap in the past, with no issues. Not very complex usage though (no keychords etc) but actively used as core feature of my app for several years.

houshuang avatar May 25 '20 13:05 houshuang

react-hotkeys v1.x uses mousetrap, and had reached a very stable state before v2 was published.

ZYinMD avatar Jun 11 '20 21:06 ZYinMD

Another vote for mousetrap here. Though, it does have some smelly bits. For example, when developing my todoist-shortcuts browser extension, I noticed that it has an arbitrary time limit of 1 second for completing a key sequence, so my fork removes that.

mgsloan avatar Jun 14 '20 04:06 mgsloan

@mgsloan the details of the underlying library are mostly abstracted away. So I don't think the dev experience would differ that much between the options.
https://github.com/roam-unofficial/roam-toolkit/blob/master/CONTRIBUTING.md introduces some overview of current code structure and conventions. Would be happy to answer more detailed questions on that as-well (reply mostly to previous version of the comment ;) )

Stvad avatar Jun 14 '20 21:06 Stvad

Cool, thanks for the info @Stvad. I'd edited my comment because I realized this isn't the spot to discuss my rather idiosyncratic case, which is instead tracked by #91

mgsloan avatar Jun 26 '20 03:06 mgsloan