Skip to content

Keyboard shortcuts: General improvements

Created by: umpox

Description

I noticed a few areas we can improve our keyboard shortcuts in this PR:

  • We currently rely on a single set of keyboard shortcuts everywhere (e.g. the same shortcuts in VSCode and on Sourcegraph web). This might burn us in the future (e.g. if we use a conflicting shortcut). We could modify our existing approach to pass a set of shortcuts into our ShortcutContext, this would let us vary them depending on the environment.
  • We currently rely on an NPM package @slimsag/react-shortcuts that doesn't appear to have a public repository. We should bring this in-house, as it is already a fork of a Shopify package.
  • We have a series of shortcuts that do not use this method for keyboard shortcuts. We should update these.

AC:

  1. Bring @slimsag/react-shortcuts in-house and move it, and useKeyboardShortcut to Wildcard.
  2. Update ShortcutProvider to take a set of shortcuts, make useKeyboardShortcut retrieve these from this context. This will let us vary keyboard shortcuts depending on the environment (VSCode, Web, Browser ext, etc)
  3. Triage any non-compliant keyboard shortcuts and move them to this pattern, so they are more discoverable and consistent.