andymatuschak / orbit

Experimental spaced repetition platform for exploring ideas in memory augmentation and programmable attention
https://withorbit.com
Other
1.71k stars 54 forks source link

Add keyboard shortcuts for review sessions #218

Closed ghost closed 3 years ago

ghost commented 3 years ago

Added an useKey hook and implemented the default actions (Space: Reveal -> Remembered) and 1/2 for the list of actions (Forgotten and Remembered for now).

Currently there is no hint for the shortcuts. I think we could show it while hovering the buttons.

Also, noticed there is logic for pendingOutcomeChange which is called when the user is interacting with one of the actions. Should we call pendingOutcomeChange on keydown and only call the handlers on keyup to make use of this API? If yes, we should probably move the shortcut handling logic inside Button.tsx.

Note: Storybook focuses the sidebar when pressing 1 (just keep that in mind while testing).

165

ghost commented 3 years ago

Whoops, forgot to lint. Will push a fix!

ghost commented 3 years ago

Refactored quite a bit to make sure we only use hooks at the top level. Let me know what you think @andymatuschak!