Skip to content

Commit 65f5770

Browse files
committed
(#409) Only sleep on keyboard inputs if autoDelay > 0
1 parent c5fb450 commit 65f5770

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/keyboard.class.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ export class KeyboardClass {
4646
try {
4747
if (inputIsString(input)) {
4848
for (const char of input.join(" ").split("")) {
49-
await sleep(this.config.autoDelayMs);
50-
await this.providerRegistry.getKeyboard().type(char);
49+
if (this.config.autoDelayMs > 0) {
50+
await sleep(this.config.autoDelayMs);
51+
}
52+
await this.providerRegistry.getKeyboard().type(char);
5153
}
5254
} else {
5355
await this.providerRegistry.getKeyboard().click(...input as Key[]);
@@ -73,7 +75,9 @@ export class KeyboardClass {
7375
public pressKey(...keys: Key[]): Promise<KeyboardClass> {
7476
return new Promise<KeyboardClass>(async (resolve, reject) => {
7577
try {
76-
await sleep(this.config.autoDelayMs);
78+
if (this.config.autoDelayMs > 0) {
79+
await sleep(this.config.autoDelayMs);
80+
}
7781
await this.providerRegistry.getKeyboard().pressKey(...keys);
7882
resolve(this);
7983
} catch (e) {
@@ -96,7 +100,9 @@ export class KeyboardClass {
96100
public releaseKey(...keys: Key[]): Promise<KeyboardClass> {
97101
return new Promise<KeyboardClass>(async (resolve, reject) => {
98102
try {
99-
await sleep(this.config.autoDelayMs);
103+
if (this.config.autoDelayMs > 0) {
104+
await sleep(this.config.autoDelayMs);
105+
}
100106
await this.providerRegistry.getKeyboard().releaseKey(...keys);
101107
resolve(this);
102108
} catch (e) {

0 commit comments

Comments
 (0)