Types
This section documents the core types used throughout the invokey library. These types define the configuration options and interfaces that shape how keyboard shortcuts behave in your application. Understanding these types is essential for effectively implementing and customizing keyboard shortcuts to match your application’s needs.
Enabled
Section titled “Enabled”type Enabled = boolean | ((event: KeyboardEvent) => boolean);
Type definition for enabling/disabling keyboard shortcuts. Can be a boolean or a function that takes a KeyboardEvent and returns a boolean.
Options
Section titled “Options”type Options = { seperator?: string; ref?: HTMLElement | null; preventDefault?: Enabled; enabled?: Enabled; disabledOnTags?: string[]; disabledOnFormTags?: boolean; disabledOnContentEditable?: boolean; scope?: string;};
Common configuration options for keyboard shortcuts.
seperator
: Character used to separate keys in a sequenceref
: Reference to the DOM element to attach the keyboard listener topreventDefault
: Whether to prevent default browser behaviorenabled
: Whether the shortcut is enableddisabledOnTags
: List of HTML tags where shortcuts should be disableddisabledOnFormTags
: Whether to disable shortcuts on form elementsdisabledOnContentEditable
: Whether to disable shortcuts on contentEditable elementsscope
: The scope this shortcut belongs to
CombinationOptions
Section titled “CombinationOptions”type CombinationOptions = Options & {};
Configuration options for keyboard combination shortcuts. Extends the base Options type.
SequenceOptions
Section titled “SequenceOptions”type SequenceOptions = Options & { timeout?: number; ignoreModifiers?: boolean;};
Configuration options for keyboard sequence shortcuts. Extends the base Options type with additional sequence-specific options
timeout
: Maximum time (in milliseconds) allowed between key presses in a sequenceignoreModifiers
: Whether to ignore modifier keys (Ctrl, Alt, Shift, Meta) in the sequence
CombinationHandler
Section titled “CombinationHandler”export type CombinationHandler = ( event: KeyboardEvent, combination: string) => void;
Type definition for the handler function used in sequence shortcuts.
SequenceHandler
Section titled “SequenceHandler”export type SequenceHandler = (event: KeyboardEvent, sequence: string) => void;
Type definition for the handler function used in sequence shortcuts.