Raxol.Core.KeyboardShortcutsBehaviour behaviour (Raxol v2.0.1)

View Source

Behavior for KeyboardShortcuts implementation.

This defines the expected interface for keyboard shortcuts functionality used by the UX refinement system.

Summary

Callbacks

Clean up the keyboard shortcuts system.

Get available shortcuts for the current context.

Get shortcuts for a specific context.

Handle keyboard events.

Initialize the keyboard shortcuts system.

Register a keyboard shortcut with callback.

Set the current shortcuts context.

Show shortcuts help.

Callbacks

cleanup()

@callback cleanup() :: :ok | {:error, term()}

Clean up the keyboard shortcuts system.

get_available_shortcuts()

@callback get_available_shortcuts() :: [map()]

Get available shortcuts for the current context.

get_shortcuts_for_context(context)

@callback get_shortcuts_for_context(context :: atom() | nil) :: term()

Get shortcuts for a specific context.

handle_keyboard_event(atom, term)

@callback handle_keyboard_event(atom(), term()) :: :ok | {:error, term()}

Handle keyboard events.

init()

@callback init() :: :ok | {:error, term()}

Initialize the keyboard shortcuts system.

register_shortcut(shortcut_key, name, callback, opts)

@callback register_shortcut(
  shortcut_key :: String.t(),
  name :: String.t(),
  callback :: function(),
  opts :: Keyword.t()
) :: :ok | {:error, term()}

Register a keyboard shortcut with callback.

set_context(context)

@callback set_context(context :: atom()) :: :ok | {:error, term()}

Set the current shortcuts context.

show_shortcuts_help(user_prefs)

@callback show_shortcuts_help(user_prefs :: term()) :: :ok | {:error, term()}

Show shortcuts help.