Skip to content

Commit

Permalink
Merge pull request octalmage#560 from Kyusung4698/master
Browse files Browse the repository at this point in the history
- remove random sleep for decreased delay while typing
  • Loading branch information
oktapodia authored Apr 22, 2020
2 parents 56c2e03 + 65da4f9 commit eee4ec5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/keypress.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
/* Convenience wrappers around ugly APIs. */
#if defined(IS_WINDOWS)
#define WIN32_KEY_EVENT_WAIT(key, flags) \
(win32KeyEvent(key, flags), Sleep(DEADBEEF_RANDRANGE(63, 125)))
(win32KeyEvent(key, flags))
#elif defined(USE_X11)
#define X_KEY_EVENT(display, key, is_press) \
(XTestFakeKeyEvent(display, \
XKeysymToKeycode(display, key), \
is_press, CurrentTime), \
XSync(display, false))
#define X_KEY_EVENT_WAIT(display, key, is_press) \
(X_KEY_EVENT(display, key, is_press), \
microsleep(DEADBEEF_UNIFORM(62.5, 125.0)))
(X_KEY_EVENT(display, key, is_press))
#endif

#if defined(IS_MACOSX)
Expand Down Expand Up @@ -316,7 +315,7 @@ void typeStringDelayed(const char *str, const unsigned cpm)
unicodeTap(n);

if (mspc > 0) {
microsleep(mspc + (DEADBEEF_UNIFORM(0.0, 62.5)));
microsleep(mspc);
}
}
}
5 changes: 4 additions & 1 deletion src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,11 @@ NAN_METHOD(keyTap)
return Nan::ThrowError("Invalid key code specified.");
break;
default:
tapKeyCode(key, flags);
toggleKeyCode(key, true, flags);
microsleep(keyboardDelay);
toggleKeyCode(key, false, flags);
microsleep(keyboardDelay);
break;
}

info.GetReturnValue().Set(Nan::New(1));
Expand Down

0 comments on commit eee4ec5

Please sign in to comment.