-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
whenipress.d.ts
44 lines (40 loc) · 1.81 KB
/
whenipress.d.ts
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
declare module 'whenipress' {
type Handler = (event?: Event) => void;
type WhenIPressPlugin = Partial<{
mounted: (globalInstance: PendingKeyboardEventManager) => void;
bindingRegistered: (binding: string[], globalInstance: PendingKeyboardEventManager) => void;
bindingStopped: (binding: string[], globalInstance: PendingKeyboardEventManager) => void;
allBindingsStopped: (globalInstance: PendingKeyboardEventManager) => void;
beforeBindingHandled: (binding: string[], globalInstance: PendingKeyboardEventManager) => boolean | void;
afterBindingHandled: (binding: string[], globalInstance: PendingKeyboardEventManager) => void;
}>
class PendingKeyboardEvent {
constructor(manager: PendingKeyboardEventManager, ...keys: string[]);
then(handler: Handler): this;
do(handler: Handler): this;
run(handler: Handler): this;
whenReleased(handler: Handler): this;
once(): this;
twiceRapidly(timeout?: number): this;
evenOnForms(): this;
whileFocusIsWithin(element: string | Element): this;
stop(): void;
createKeyDownHandler(handler: Handler): void;
createKeyUpHandler(handler: Handler): void;
}
class PendingKeyboardEventManager {
registerFocusListeners(): void;
register(...keys: string[]): PendingKeyboardEvent;
group(keys: string | string[], handler: Handler): void;
use(...plugins: WhenIPressPlugin[]): void;
pluginWithOptions<T extends object>(plugin: WhenIPressPlugin, options: T): {
plugin: WhenIPressPlugin;
options: T;
}
flushPlugins(): void;
bindings(): string[][];
stopAll(): void;
}
export default function whenipress(): PendingKeyboardEventManager;
export default function whenipress(...keys: string[]): PendingKeyboardEvent;
}