UNPKG

1.61 kBTypeScriptView Raw
1import { type Instance } from '../setup';
2import { type System } from '.';
3export declare enum DOM_KEY_LOCATION {
4 STANDARD = 0,
5 LEFT = 1,
6 RIGHT = 2,
7 NUMPAD = 3
8}
9export interface keyboardKey {
10 /** Physical location on a keyboard */
11 code?: string;
12 /** Character or functional key descriptor */
13 key?: string;
14 /** Location on the keyboard for keys with multiple representation */
15 location?: DOM_KEY_LOCATION;
16 /** Does the character in `key` require/imply AltRight to be pressed? */
17 altGr?: boolean;
18 /** Does the character in `key` require/imply a shiftKey to be pressed? */
19 shift?: boolean;
20}
21export declare class KeyboardHost {
22 readonly system: System;
23 constructor(system: System);
24 readonly modifiers: {
25 Alt: boolean;
26 AltGraph: boolean;
27 CapsLock: boolean;
28 Control: boolean;
29 Fn: boolean;
30 FnLock: boolean;
31 Meta: boolean;
32 NumLock: boolean;
33 ScrollLock: boolean;
34 Shift: boolean;
35 Symbol: boolean;
36 SymbolLock: boolean;
37 };
38 readonly pressed: Record<string, {
39 keyDef: keyboardKey;
40 unpreventedDefault: boolean;
41 }>;
42 carryChar: string;
43 private lastKeydownTarget;
44 private readonly modifierLockStart;
45 isKeyPressed(keyDef: keyboardKey): boolean;
46 getPressedKeys(): keyboardKey[];
47 /** Press a key */
48 keydown(instance: Instance, keyDef: keyboardKey): Promise<void>;
49 /** Release a key */
50 keyup(instance: Instance, keyDef: keyboardKey): Promise<void>;
51 private setKeydownTarget;
52 private hasKeyPress;
53}