1 | export interface HotkeysEvent {
|
2 | key: string;
|
3 | method: KeyHandler;
|
4 | mods: number[];
|
5 | scope: string;
|
6 | shortcut: string;
|
7 | }
|
8 |
|
9 | export interface KeyHandler {
|
10 | (keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent): void | boolean;
|
11 | }
|
12 |
|
13 | type Options = {
|
14 | scope?: string;
|
15 | element?: HTMLElement | null;
|
16 | keyup?: boolean | null;
|
17 | keydown?: boolean | null;
|
18 | capture?: boolean
|
19 | splitKey?: string;
|
20 | }
|
21 |
|
22 | export interface Hotkeys {
|
23 | (key: string, method: KeyHandler): void;
|
24 | (key: string, scope: string, method: KeyHandler): void;
|
25 | (key: string, options: Options, method: KeyHandler): void;
|
26 |
|
27 | shift: boolean;
|
28 | ctrl: boolean;
|
29 | alt: boolean;
|
30 | option: boolean;
|
31 | control: boolean;
|
32 | cmd: boolean;
|
33 | command: boolean;
|
34 |
|
35 | keyMap: Record<string, number>;
|
36 | modifier: Record<string, number>;
|
37 | modifierMap: Record<string, number | string>;
|
38 |
|
39 | setScope(scopeName: string): void;
|
40 | getScope(): string;
|
41 | deleteScope(scopeName: string, newScopeName?: string): void;
|
42 |
|
43 | noConflict(): Hotkeys;
|
44 |
|
45 | trigger(shortcut: string, scope?: string): void;
|
46 |
|
47 | unbind(key?: string): void;
|
48 | unbind(key: string, scopeName: string): void;
|
49 | unbind(key: string, scopeName: string, method: KeyHandler): void;
|
50 | unbind(key: string, method: KeyHandler): void;
|
51 |
|
52 | isPressed(keyCode: number): boolean;
|
53 | isPressed(keyCode: string): boolean;
|
54 | getPressedKeyCodes(): number[];
|
55 |
|
56 | filter(event: KeyboardEvent): boolean;
|
57 | }
|
58 |
|
59 | declare var hotkeys: Hotkeys;
|
60 | export default hotkeys;
|