UNPKG

1.71 kBTypeScriptView Raw
1/// <reference types="react" />
2export interface HotkeyConfig {
3 /**
4 * Whether the hotkey should be triggerable when focused in a text input.
5 *
6 * @default false
7 */
8 allowInInput?: boolean;
9 /**
10 * Hotkey combination string (AKA "key combo"), such as "space" or "cmd+n".
11 */
12 combo: string;
13 /**
14 * Whether the hotkey cannot be triggered.
15 *
16 * @default false
17 */
18 disabled?: boolean;
19 /**
20 * Human-friendly label for the hotkey.
21 */
22 label: React.ReactNode;
23 /**
24 * If `false`, the hotkey is active only when the target is focused. If
25 * `true`, the hotkey can be triggered regardless of what component is
26 * focused.
27 *
28 * @default false
29 */
30 global?: boolean;
31 /**
32 * Unless the hotkey is global, you must specify a group where the hotkey
33 * will be displayed in the hotkeys dialog. This string will be displayed
34 * in a header at the start of the group of hotkeys.
35 */
36 group?: string;
37 /**
38 * When `true`, invokes `event.preventDefault()` before the respective `onKeyDown` and
39 * `onKeyUp` callbacks are invoked. Enabling this can simplify handler implementations.
40 *
41 * @default false
42 */
43 preventDefault?: boolean;
44 /**
45 * When `true`, invokes `event.stopPropagation()` before the respective `onKeyDown` and
46 * `onKeyUp` callbacks are invoked. Enabling this can simplify handler implementations.
47 *
48 * @default false
49 */
50 stopPropagation?: boolean;
51 /**
52 * `keydown` event handler.
53 */
54 onKeyDown?(e: KeyboardEvent): any;
55 /**
56 * `keyup` event handler.
57 */
58 onKeyUp?(e: KeyboardEvent): any;
59}