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 | splitKey?: string;
|
19 | }
|
20 |
|
21 | interface Hotkeys {
|
22 | (key: string, method: KeyHandler): void
|
23 | (key: string, scope: string, method: KeyHandler): void
|
24 | (key: string, options: Options, method: KeyHandler): void
|
25 |
|
26 | shift: boolean
|
27 | ctrl: boolean
|
28 | alt: boolean
|
29 | option: boolean
|
30 | control: boolean
|
31 | cmd: boolean
|
32 | command: boolean
|
33 |
|
34 | setScope(scopeName: string): void
|
35 | getScope(): string
|
36 | deleteScope(scopeName: string): void
|
37 |
|
38 | noConflict(): void
|
39 |
|
40 | unbind(key: string): void
|
41 | unbind(key: string, scopeName: string): void
|
42 | unbind(key: string, scopeName: string, method: KeyHandler): void
|
43 | unbind(key: string, method: KeyHandler): void
|
44 |
|
45 | isPressed(keyCode: number): boolean
|
46 | isPressed(keyCode: string): boolean
|
47 | getPressedKeyCodes(): number[]
|
48 |
|
49 | filter(event: KeyboardEvent): boolean
|
50 | }
|
51 |
|
52 | declare var hotkeys: Hotkeys
|
53 | export default hotkeys;
|