1 | export declare type KeySequence = KeyCode[];
|
2 | export declare namespace KeySequence {
|
3 | function equals(a: KeySequence, b: KeySequence): boolean;
|
4 | enum CompareResult {
|
5 | NONE = 0,
|
6 | PARTIAL = 1,
|
7 | SHADOW = 2,
|
8 | FULL = 3
|
9 | }
|
10 | function compare(a: KeySequence, b: KeySequence): CompareResult;
|
11 | function parse(keybinding: string): KeySequence;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export interface Keystroke {
|
20 | readonly first?: Key;
|
21 | readonly modifiers?: KeyModifier[];
|
22 | }
|
23 | export interface KeyCodeSchema {
|
24 | key?: Partial<Key>;
|
25 | ctrl?: boolean;
|
26 | shift?: boolean;
|
27 | alt?: boolean;
|
28 | meta?: boolean;
|
29 | character?: string;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 | export declare class KeyCode {
|
35 | readonly key: Key | undefined;
|
36 | readonly ctrl: boolean;
|
37 | readonly shift: boolean;
|
38 | readonly alt: boolean;
|
39 | readonly meta: boolean;
|
40 | readonly character: string | undefined;
|
41 | constructor(schema: KeyCodeSchema);
|
42 | /**
|
43 | * Return true if this KeyCode only contains modifiers.
|
44 | */
|
45 | isModifierOnly(): boolean;
|
46 | /**
|
47 | * Return true if the given KeyCode is equal to this one.
|
48 | */
|
49 | equals(other: KeyCode): boolean;
|
50 | toString(): string;
|
51 | /**
|
52 | * Create a KeyCode from one of several input types.
|
53 | */
|
54 | static createKeyCode(input: KeyboardEvent | Keystroke | KeyCodeSchema | string, eventDispatch?: 'code' | 'keyCode'): KeyCode;
|
55 | private static keybindings;
|
56 | static resetKeyBindings(): void;
|
57 | /**
|
58 | * Parses a string and returns a KeyCode object.
|
59 | * @param keybinding String representation of a keybinding
|
60 | */
|
61 | static parse(keybinding: string): KeyCode;
|
62 | }
|
63 | export declare namespace KeyCode {
|
64 | |
65 |
|
66 |
|
67 | type Predicate = (keyCode: KeyCode) => boolean;
|
68 | function isModifierString(key: string): boolean;
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | function isKeyboardEvent(event: object & {
|
79 | readonly type?: string;
|
80 | }): event is KeyboardEvent;
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | function toKey(event: KeyboardEvent, dispatch?: 'code' | 'keyCode'): Key;
|
89 | |
90 |
|
91 |
|
92 |
|
93 |
|
94 | function toCharacter(event: KeyboardEvent): string | undefined;
|
95 | }
|
96 | export declare enum KeyModifier {
|
97 | |
98 |
|
99 |
|
100 | CtrlCmd = "M1",
|
101 | |
102 |
|
103 |
|
104 | Shift = "M2",
|
105 | |
106 |
|
107 |
|
108 | Alt = "M3",
|
109 | |
110 |
|
111 |
|
112 | MacCtrl = "M4"
|
113 | }
|
114 | export declare namespace KeyModifier {
|
115 | |
116 |
|
117 |
|
118 |
|
119 | const CTRL: KeyModifier.MacCtrl | KeyModifier.CtrlCmd;
|
120 | |
121 |
|
122 |
|
123 | const SHIFT: KeyModifier.Shift;
|
124 | |
125 |
|
126 |
|
127 | function isModifier(key: string | undefined): boolean;
|
128 | }
|
129 | export interface Key {
|
130 | readonly code: string;
|
131 | readonly keyCode: number;
|
132 | readonly easyString: string;
|
133 | }
|
134 | export declare namespace SpecialCases {
|
135 | const META = "meta";
|
136 | const CTRLCMD = "ctrlcmd";
|
137 | }
|
138 | export declare namespace Key {
|
139 | function isKey(arg: unknown): arg is Key;
|
140 | function getKey(arg: string | number): Key | undefined;
|
141 | function isModifier(arg: string | number): boolean;
|
142 | function equals(key: Key, keyCode: KeyCode): boolean;
|
143 | const BACKSPACE: Key;
|
144 | const TAB: Key;
|
145 | const ENTER: Key;
|
146 | const ESCAPE: Key;
|
147 | const SPACE: Key;
|
148 | const PAGE_UP: Key;
|
149 | const PAGE_DOWN: Key;
|
150 | const END: Key;
|
151 | const HOME: Key;
|
152 | const ARROW_LEFT: Key;
|
153 | const ARROW_UP: Key;
|
154 | const ARROW_RIGHT: Key;
|
155 | const ARROW_DOWN: Key;
|
156 | const INSERT: Key;
|
157 | const DELETE: Key;
|
158 | const SHIFT_LEFT: Key;
|
159 | const SHIFT_RIGHT: Key;
|
160 | const CONTROL_LEFT: Key;
|
161 | const CONTROL_RIGHT: Key;
|
162 | const ALT_LEFT: Key;
|
163 | const ALT_RIGHT: Key;
|
164 | const CAPS_LOCK: Key;
|
165 | const OS_LEFT: Key;
|
166 | const OS_RIGHT: Key;
|
167 | const DIGIT0: Key;
|
168 | const DIGIT1: Key;
|
169 | const DIGIT2: Key;
|
170 | const DIGIT3: Key;
|
171 | const DIGIT4: Key;
|
172 | const DIGIT5: Key;
|
173 | const DIGIT6: Key;
|
174 | const DIGIT7: Key;
|
175 | const DIGIT8: Key;
|
176 | const DIGIT9: Key;
|
177 | const KEY_A: Key;
|
178 | const KEY_B: Key;
|
179 | const KEY_C: Key;
|
180 | const KEY_D: Key;
|
181 | const KEY_E: Key;
|
182 | const KEY_F: Key;
|
183 | const KEY_G: Key;
|
184 | const KEY_H: Key;
|
185 | const KEY_I: Key;
|
186 | const KEY_J: Key;
|
187 | const KEY_K: Key;
|
188 | const KEY_L: Key;
|
189 | const KEY_M: Key;
|
190 | const KEY_N: Key;
|
191 | const KEY_O: Key;
|
192 | const KEY_P: Key;
|
193 | const KEY_Q: Key;
|
194 | const KEY_R: Key;
|
195 | const KEY_S: Key;
|
196 | const KEY_T: Key;
|
197 | const KEY_U: Key;
|
198 | const KEY_V: Key;
|
199 | const KEY_W: Key;
|
200 | const KEY_X: Key;
|
201 | const KEY_Y: Key;
|
202 | const KEY_Z: Key;
|
203 | const MULTIPLY: Key;
|
204 | const ADD: Key;
|
205 | const DECIMAL: Key;
|
206 | const SUBTRACT: Key;
|
207 | const DIVIDE: Key;
|
208 | const F1: Key;
|
209 | const F2: Key;
|
210 | const F3: Key;
|
211 | const F4: Key;
|
212 | const F5: Key;
|
213 | const F6: Key;
|
214 | const F7: Key;
|
215 | const F8: Key;
|
216 | const F9: Key;
|
217 | const F10: Key;
|
218 | const F11: Key;
|
219 | const F12: Key;
|
220 | const F13: Key;
|
221 | const F14: Key;
|
222 | const F15: Key;
|
223 | const F16: Key;
|
224 | const F17: Key;
|
225 | const F18: Key;
|
226 | const F19: Key;
|
227 | const F20: Key;
|
228 | const F21: Key;
|
229 | const F22: Key;
|
230 | const F23: Key;
|
231 | const F24: Key;
|
232 | const NUM_LOCK: Key;
|
233 | const SEMICOLON: Key;
|
234 | const EQUAL: Key;
|
235 | const COMMA: Key;
|
236 | const MINUS: Key;
|
237 | const PERIOD: Key;
|
238 | const SLASH: Key;
|
239 | const BACKQUOTE: Key;
|
240 | const INTL_RO: Key;
|
241 | const BRACKET_LEFT: Key;
|
242 | const BACKSLASH: Key;
|
243 | const BRACKET_RIGHT: Key;
|
244 | const QUOTE: Key;
|
245 | const INTL_BACKSLASH: Key;
|
246 | const INTL_YEN: Key;
|
247 | const MAX_KEY_CODE: number;
|
248 | }
|
249 | export declare type KeysOrKeyCodes = Key | KeyCode | (Key | KeyCode)[];
|
250 | export declare namespace KeysOrKeyCodes {
|
251 | const toKeyCode: (keyOrKeyCode: Key | KeyCode) => KeyCode;
|
252 | const toKeyCodes: (keysOrKeyCodes: KeysOrKeyCodes) => KeyCode[];
|
253 | }
|
254 |
|
\ | No newline at end of file |