Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global hotkey (shortcuts) management #6313

Open
ShGKme opened this issue Dec 19, 2024 · 0 comments
Open

Add global hotkey (shortcuts) management #6313

ShGKme opened this issue Dec 19, 2024 · 0 comments
Labels
0. to triage enhancement New feature or request

Comments

@ShGKme
Copy link
Contributor

ShGKme commented Dec 19, 2024

Problem

Currently, we have hotkeys (shortcuts) in many apps and components. It includes:

  1. Setting the global hotkey listener taking into account a11y, macOS, and focus
  2. Showing the keymap

While setting the hotkey listener is covered by useHotkey, showing "Keyboard shortcuts" is implemented manually by apps.

Files Talk
image image

It results in the following problems:

  • Each app must implement the settings section again
  • Each app should include global shortcuts like new n</kbd< for App Navigation toggle
  • Consistency and relevance:
    • Design consistency
    • Open dialog by ? (not implemented by Talk)
    • macOS - Ctrl is replaced with Cmd on macOS (not implemented by Files)
    • Manual update - after adding the hotkey developers should not forget to add it to the docs (especially with global hotkeys)

Proposal

Add a global shortcut manager together with useHotkey

  1. When registering a hotkey, allow defining:
    • Description, e.g. Select all files
    • Section, e.g. Actions
    • App (can be defined automatically from NcContent), e.g. Files or Global for all-apps
  2. Store the fact of hotkey registration globally in window
  3. Add components <NcHotkeys> and <NcHotkeysDialog> with the list of hotkeys and ?

Implementation notes

We might use useHotkey to handle the fact of (un)registration. But some hotkeys are registered only in a specific context like a call in Talk. So we don't know about a hotkey in advance.

Instead, we can add an app-level composable like

declare function useAppHotkey(options: { id: string, key: string, description: string, section?: string })

useAppHotkey()

Then useHotkey should refer to a registered app hotkey (via id or a new composable wrapper).

Vue

Implementing it as a composable allows automatic unregistration and useHotkey integration.

But the functionality might make sense even without Vue. Maybe it should be also available outside composables and the vue library.

@ShGKme ShGKme added enhancement New feature or request 0. to triage labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. to triage enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant