Pular para o conteúdo

Shortcut Listener

Este conteúdo não está disponível em sua língua ainda.

The ShortcutListener component listens for specific key combinations and triggers a callback when they are pressed. This is useful for implementing keyboard shortcuts or hotkeys in your application.

  • Custom key combinations: Define any combination of keys to listen for.
  • Callback triggered on match: Executes a function when the shortcut is detected.
  • Supports modifier keys: Works with Ctrl, Alt, Shift, and Meta.

waiting...

Press Ctrl + C

or

Press Ctrl + V

PropTypeDefaultDescription
keysstring[][]Array of keys or key names that form the shortcut combination.
callback(event: KeyboardEvent) => voidFunction called when the specified keys are pressed.
disabledbooleanfalseWhether the listener is inactive.
oncebooleanfalseIf true, the callback is triggered only once per mount.
  • Use Kbd component to display key combinations in the UI.
  • Avoid conflicts with native browser shortcuts.
  • Combine modifier keys and regular keys to create custom shortcuts.
  • Disable listeners when not needed to prevent unwanted triggers.