1 | import { EventEmitter } from 'events';
|
2 |
|
3 | /**
|
4 | * Native module for hooking keyboard and mouse events
|
5 | */
|
6 | declare class IOHook extends EventEmitter {
|
7 | /**
|
8 | * Start hooking engine. Call it when you ready to receive events
|
9 | * @param {boolean} [enableLogger] If true, module will publish debug information to stdout
|
10 | */
|
11 | start(enableLogger?: boolean): void;
|
12 |
|
13 | /**
|
14 | * Stop rising keyboard/mouse events
|
15 | */
|
16 | stop(): void;
|
17 |
|
18 | /**
|
19 | * Manual native code load. Call this function only if unload called before
|
20 | */
|
21 | load(): void;
|
22 |
|
23 | /**
|
24 | * Unload native code and free memory and system hooks
|
25 | */
|
26 | unload(): void;
|
27 |
|
28 | /**
|
29 | * Enable/Disable stdout debug
|
30 | * @param {boolean} mode
|
31 | */
|
32 | setDebug(mode: boolean): void;
|
33 |
|
34 | /**
|
35 | * Specify that key event's `rawcode` property should be used instead of
|
36 | * `keycode` when listening for key presses.
|
37 | *
|
38 | * This allows iohook to be used in conjunction with other programs that may
|
39 | * only provide a keycode.
|
40 | * @param {Boolean} using
|
41 | */
|
42 | useRawcode(using: boolean): void;
|
43 |
|
44 | /**
|
45 | * Enable mouse click propagation (enabled by default).
|
46 | * The click event are emitted and propagated.
|
47 | */
|
48 | enableClickPropagation(): void;
|
49 |
|
50 | /**
|
51 | * Disable mouse click propagation.
|
52 | * The click event are captured and the event emitted but not propagated to the window.
|
53 | */
|
54 | disableClickPropagation(): void;
|
55 |
|
56 | /**
|
57 | * Register global shortcut. When all keys in keys array pressed, callback will be called
|
58 | * @param {Array<string|number>} keys Array of keycodes
|
59 | * @param {Function} callback Callback for when shortcut pressed
|
60 | * @param {Function} [releaseCallback] Callback for when shortcut released
|
61 | * @return {number} ShortcutId for unregister
|
62 | */
|
63 | registerShortcut(
|
64 | keys: Array<string | number>,
|
65 | callback: Function,
|
66 | releaseCallback?: Function
|
67 | ): number;
|
68 |
|
69 | /**
|
70 | * Unregister shortcut by ShortcutId
|
71 | * @param {number} shortcutId
|
72 | */
|
73 | unregisterShortcut(shortcutId: number): void;
|
74 |
|
75 | /**
|
76 | * Unregister shortcut via its key codes
|
77 | * @param {Array<string|number>} keys
|
78 | */
|
79 | unregisterShortcut(keys: Array<string | number>): void;
|
80 |
|
81 | /**
|
82 | * Unregister all shortcuts
|
83 | */
|
84 | unregisterAllShortcuts(): void;
|
85 | }
|
86 |
|
87 | declare interface IOHookEvent {
|
88 | type: string;
|
89 | keychar?: number;
|
90 | keycode?: number;
|
91 | rawcode?: number;
|
92 | button?: number;
|
93 | clicks?: number;
|
94 | x?: number;
|
95 | y?: number;
|
96 | }
|
97 |
|
98 | declare const iohook: IOHook;
|
99 |
|
100 | export = iohook;
|