/** * Represents the base keys that can be handled by the keyboard event handler. * * This type includes a variety of common keyboard keys, such as: * - Control keys (e.g., 'backspace', 'delete', 'insert', 'tab', 'enter', etc.) * - Navigation keys (e.g., 'left', 'up', 'right', 'down', 'home', 'end', etc.) * - Modifier keys (e.g., 'shift', 'ctrl', 'alt', etc.) * * This type can be extended with additional keys as needed. * * @example * ```typescript * const key: IKeyboardEventHandlerBaseKey = 'enter'; // Valid key * const anotherKey: IKeyboardEventHandlerBaseKey = 'backspace'; // Valid key * const invalidKey: IKeyboardEventHandlerBaseKey = 'unknown'; // TypeScript will throw an error * ``` */ export type IKeyboardEventHandlerBaseKey = 'backspace' | '"' | 'del' | '\'' | ',' | 'delete' | 'ins' | 'insert' | 'tab' | 'enter' | 'return' | 'esc' | 'space' | 'pageup' | 'pagedown' | 'end' | 'home' | 'left' | 'up' | 'right' | 'down' | 'shift' | 'ctrl' | 'alt' | 'cap' | 'num' | 'clear' | 'meta' | ';' | '=' | '|' | '-' | 'minus' | '.' | '/' | '`' | '[' | '\\' | ']' | '*' | '+' | 'plus' | '\\' | 'quote' | string; /** * Represents the modifier keys that can be used in keyboard event handling. * * This type includes common modifier keys such as: * - 'control' or 'ctrl' * - 'command' or 'cmd' * - 'shift' * - 'meta' * - 'option' or 'alt' * * These keys can be combined with base keys to create complex key combinations. * * @example * ```typescript * const modifier: IKeyboardEventHandlerModifierKeys = 'ctrl'; // Valid modifier * const anotherModifier: IKeyboardEventHandlerModifierKeys = 'shift'; // Valid modifier * const invalidModifier: IKeyboardEventHandlerModifierKeys = 'unknown'; // TypeScript will throw an error * ``` */ export type IKeyboardEventHandlerModifierKeys = 'control' | 'ctrl' | 'command' | 'shift' | 'meta' | 'cmd' | 'option' | 'alt'; /** * Represents a key that can be handled by the keyboard event handler, * which can be either a base key or a combination of modifier keys and a base key. * * This type allows for the definition of complex key combinations, such as: * - 'ctrl+a' (Control + A) * - 'shift+tab' (Shift + Tab) * - 'alt+f4' (Alt + F4) * * @example * ```typescript * const keyCombination: IKeyboardEventHandlerKey = 'ctrl+z'; // Valid combination * const anotherKeyCombination: IKeyboardEventHandlerKey = 'shift+enter'; // Valid combination * const baseKey: IKeyboardEventHandlerKey = 'space'; // Valid base key * ``` */ export type IKeyboardEventHandlerKey = `${IKeyboardEventHandlerModifierKeys}+${IKeyboardEventHandlerBaseKey}` | IKeyboardEventHandlerBaseKey; /** * Finds the matched key from a keyboard event based on the provided keys. * * This function takes a keyboard event and an array of keys, and checks if any of the keys * match the event. It also supports key aliases and can return a special value if 'all' is included * in the keys array. * * @param event - The keyboard event to check against the provided keys. * This can be any event object that contains key information. * Example: * ```typescript * const event = { key: 'Enter', type: 'keydown' }; * ``` * @param keys - An array of keys to match against the event. * This can include base keys, modifier keys, or aliases. * Example: * ```typescript * const keys = ['enter', 'space', 'ctrl+a', 'all']; * ``` * * @returns The matched key as an `IKeyboardEventHandlerKey`. * If no key matches and 'all' is included in the keys, it returns 'other'. * If no match is found, it returns `undefined`. * * @example * ```typescript * const event = { key: 'Enter', type: 'keydown' }; * const keys = ['enter', 'space', 'ctrl+a']; * const matchedKey = findMatchedKey(event, keys); * console.log(matchedKey); // Output: 'enter' * ``` * * @example * ```typescript * const event = { key: 'Escape', type: 'keydown' }; * const keys = ['all']; * const matchedKey = findMatchedKey(event, keys); * console.log(matchedKey); // Output: 'other' * ``` */ export declare function findMatchedKey(event: any, keys: string[]): IKeyboardEventHandlerKey;