@tanstack/hotkeys
Version:
Type-safe, framework-agnostic keyboard hotkey management for the browser
21 lines • 1.08 kB
TypeScript
import { RegisterableHotkey } from "./hotkey.types.js";
import { HotkeyPlatform } from "./platform.js";
export interface HeldModifierOptions {
/** Resolve Mod for this platform. Defaults to platform detection. */
platform?: HotkeyPlatform;
/** Require every binding modifier to be held. Default: false (nonempty subset). */
exact?: boolean;
}
/**
* Returns whether held modifiers should reveal a shortcut hint.
* By default, any nonempty subset of the binding's modifiers qualifies; an
* unrelated modifier hides the hint. `exact` requires every binding modifier.
* Nonmodifier keys are ignored. This does not check registration or focus.
* A sequence reveals its hint from its first step. Returns false for no
* hotkey (`undefined`, `null`, or `''`).
*
* @example
* matchesHeldModifiers('Alt+Shift+[KeyK]', ['Alt']) // true
* matchesHeldModifiers('Alt+Shift+[KeyK]', ['Alt', 'Control']) // false
*/
export declare function matchesHeldModifiers(hotkey: RegisterableHotkey | null | undefined, heldKeys: ReadonlyArray<string>, options?: HeldModifierOptions): boolean;