@@ -8,16 +8,33 @@ const inputIsString = (input: string[] | Key[]): input is string[] => {
8
8
return input . every ( ( elem : string | Key ) => typeof elem === "string" ) ;
9
9
} ;
10
10
11
+ /**
12
+ * {@link Keyboard } class provides methods to emulate keyboard input
13
+ */
11
14
export class Keyboard {
12
15
16
+ /**
17
+ * Config object for {@link Keyboard} class
18
+ */
13
19
public config = {
20
+ /**
21
+ * Configures the delay between single key events
22
+ */
14
23
autoDelayMs : 300 ,
15
24
} ;
16
25
26
+ /**
27
+ * {@link Keyboard } class constructor
28
+ * @param nativeAdapter {@link NativeAdapter } instance which bundles access to mouse, keyboard and clipboard
29
+ */
17
30
constructor ( private nativeAdapter : NativeAdapter ) {
18
31
this . nativeAdapter . setKeyboardDelay ( this . config . autoDelayMs ) ;
19
32
}
20
33
34
+ /**
35
+ * {@link type } types a sequence of {@link String } or single {@link Key }s via system keyboard
36
+ * @param input Sequence of {@link String} or {@link Key} to type
37
+ */
21
38
public type ( ...input : StringOrKey ) : Promise < Keyboard > {
22
39
return new Promise < Keyboard > ( async ( resolve , reject ) => {
23
40
try {
@@ -36,6 +53,17 @@ export class Keyboard {
36
53
} ) ;
37
54
}
38
55
56
+ /**
57
+ * {@link pressKey } presses and holds a single {@link Key } for {@link Key } combinations
58
+ * Modifier {@link Key }s are to be given in "natural" ordering, so first modifier {@link Key}s, followed by the {@link Key} to press
59
+ * @example
60
+ * ```typescript
61
+ * // Will press and hold key combination STRG + V
62
+ * await keyboard.pressKey(Key.STRG, Key.A);
63
+ * ```
64
+ *
65
+ * @param keys Array of {@link Key}s to press and hold
66
+ */
39
67
public pressKey ( ...keys : Key [ ] ) : Promise < Keyboard > {
40
68
return new Promise < Keyboard > ( async ( resolve , reject ) => {
41
69
try {
@@ -47,6 +75,17 @@ export class Keyboard {
47
75
} ) ;
48
76
}
49
77
78
+ /**
79
+ * {@link pressKey } releases a single {@link Key } for {@link Key } combinations
80
+ * Modifier {@link Key }s are to be given in "natural" ordering, so first modifier {@link Key}s, followed by the {@link Key} to press
81
+ * @example
82
+ * ```typescript
83
+ * // Will release key combination STRG + V
84
+ * await keyboard.releaseKey(Key.STRG, Key.A);
85
+ * ```
86
+ *
87
+ * @param keys Array of {@link Key}s to release
88
+ */
50
89
public releaseKey ( ...keys : Key [ ] ) : Promise < Keyboard > {
51
90
return new Promise < Keyboard > ( async ( resolve , reject ) => {
52
91
try {
0 commit comments