-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
61 lines (52 loc) · 1.43 KB
/
types.ts
File metadata and controls
61 lines (52 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { KeyboardEvent } from 'react';
export interface KbsKeyDefinitionModifiers {
ctrl?: boolean;
alt?: boolean;
shift?: boolean;
}
export interface KbsKeyDefinitionKey extends KbsKeyDefinitionModifiers {
key: string;
}
export interface KbsKeyDefinitionCode extends KbsKeyDefinitionModifiers {
code: string;
}
export type KbsKeyDefinition = KbsKeyDefinitionKey | KbsKeyDefinitionCode;
export type KbsHandler = (
event: KeyboardEvent<HTMLDivElement> | globalThis.KeyboardEvent,
) => void;
/**
* Extend this interface to customize the metadata type.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface KbsMetadata {}
export interface KbsDefinition {
/**
* The definition of key(s) that will trigger the shortcut.
*/
shortcut:
| string
| KbsKeyDefinition
| ReadonlyArray<string | KbsKeyDefinition>;
/**
* The handler function to call when the shortcut is triggered.
*/
handler: KbsHandler;
/**
* Optional metadata to store with the shortcut.
*/
meta?: KbsMetadata;
/**
* If specified, the shortcut will be triggered at most `maxFrequency` times
* per second when a key is held down.
*/
maxFrequency?: number;
}
export interface KbsShortcut {
shortcut: KbsKeyDefinition;
aliases: readonly KbsKeyDefinition[];
meta?: KbsMetadata;
}
export interface KbsInternalShortcut extends KbsShortcut {
handler: KbsHandler;
maxFrequency: number;
}