/** * Velo Plot - Keyboard Shortcuts Module * * Provides customizable keyboard shortcuts for chart interactions. * Supports key combinations, custom actions, and enable/disable per key. * * @module keybindings */ /** Available built-in actions */ export type KeyAction = 'resetZoom' | 'autoScale' | 'zoomIn' | 'zoomOut' | 'panLeft' | 'panRight' | 'panUp' | 'panDown' | 'togglePan' | 'toggleSelect' | 'clearSelection' | 'deleteSelected' | 'selectAll' | 'copy' | 'exportImage' | 'toggleLegend' | 'toggleDebug' | 'escape' | 'undo' | 'redo' | 'custom'; /** Key binding configuration */ export interface KeyBinding { /** The key code (e.g., 'KeyR', 'Escape', 'ArrowLeft') */ key: string; /** Action to perform */ action: KeyAction; /** Require Ctrl/Cmd key */ ctrl?: boolean; /** Require Shift key */ shift?: boolean; /** Require Alt key */ alt?: boolean; /** Require Meta key (Cmd on Mac) */ meta?: boolean; /** Custom handler function (required if action is 'custom') */ handler?: () => void; /** Whether this binding is enabled (default: true) */ enabled?: boolean; /** Description for help/UI display */ description?: string; } /** Callbacks for keyboard actions */ export interface KeyBindingCallbacks { onResetZoom?: () => void; onAutoScale?: () => void; onZoomIn?: () => void; onZoomOut?: () => void; onPanLeft?: () => void; onPanRight?: () => void; onPanUp?: () => void; onPanDown?: () => void; onTogglePan?: () => void; onToggleSelect?: () => void; onClearSelection?: () => void; onDeleteSelected?: () => void; onSelectAll?: () => void; onCopy?: () => void; onExportImage?: () => void; onToggleLegend?: () => void; onToggleDebug?: () => void; onEscape?: () => void; onUndo?: () => void; onRedo?: () => void; } export interface KeyBindingManagerOptions { /** Enable keyboard shortcuts (default: true) */ enabled?: boolean; /** Custom key bindings (merged with defaults) */ bindings?: KeyBinding[]; /** Override all default bindings (replace instead of merge) */ replaceDefaults?: boolean; /** Callbacks for built-in actions */ callbacks: KeyBindingCallbacks; /** Target element for keyboard events (default: document) */ target?: HTMLElement | Document; /** Prevent default browser behavior for matched keys (default: true) */ preventDefault?: boolean; } export declare const DEFAULT_KEY_BINDINGS: KeyBinding[]; export declare class KeyBindingManager { private bindings; private callbacks; private target; private enabled; private preventDefault; private boundHandler; constructor(options: KeyBindingManagerOptions); /** * Attach keyboard event listeners */ attach(): void; /** * Detach keyboard event listeners */ detach(): void; /** * Enable/disable all keyboard shortcuts */ setEnabled(enabled: boolean): void; /** * Check if keyboard shortcuts are enabled */ isEnabled(): boolean; /** * Add a custom key binding */ addBinding(binding: KeyBinding): void; /** * Remove a key binding by key code */ removeBinding(key: string, modifiers?: { ctrl?: boolean; shift?: boolean; alt?: boolean; }): void; /** * Update an existing binding */ updateBinding(key: string, updates: Partial): void; /** * Enable/disable a specific binding */ setBindingEnabled(key: string, enabled: boolean): void; /** * Get all current bindings */ getBindings(): KeyBinding[]; /** * Get binding for a specific key */ getBinding(key: string): KeyBinding | undefined; /** * Get a formatted list of all shortcuts (for help display) */ getShortcutList(): { key: string; description: string; }[]; /** * Format a key binding for display */ formatKeyBinding(binding: KeyBinding): string; /** * Handle keydown events */ private handleKeyDown; /** * Find a binding that matches the current key event */ private findMatchingBinding; /** * Execute the action for a binding */ private executeAction; /** * Destroy the manager and cleanup */ destroy(): void; } /** * Create a simple key binding configuration */ export declare function createKeyBinding(key: string, action: KeyAction, options?: Partial): KeyBinding; /** * Parse a shortcut string (e.g., "Ctrl+R") into a KeyBinding */ export declare function parseShortcut(shortcut: string, action: KeyAction): KeyBinding;