Skip to content

Commit

Permalink
Add short delay between multiple key commands
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueM committed Nov 7, 2013
1 parent fb09613 commit 424bb4b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Actions/KeyBaseAction.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ -(void)performActionWithData:(NSString *)data

NSString *shortcut = [[self class] commandListShortcut];

struct timespec waitingtime;
waitingtime.tv_sec = 0;
waitingtime.tv_nsec = 5 * 1000000; // Milliseconds

if ([data isEqualToString:@""]) {
[NSException raise:@"InvalidCommandException"
format:@"Missing argument to command “%@”: Expected one or more keys (separated by a comma). Examples: “%@:ctrl” or “%@:cmd,alt”",
Expand All @@ -94,7 +98,7 @@ -(void)performActionWithData:(NSString *)data
}
}

// Then, "press" the key down
// Then, perform whatever action is requested
for (i = 0; i < count; i++) {
unsigned code = [[keycodes objectForKey:[keys objectAtIndex:i]] intValue];

Expand All @@ -104,6 +108,7 @@ -(void)performActionWithData:(NSString *)data
}

if (MODE_TEST != mode) {
nanosleep(&waitingtime, NULL);
[self performActionWithKeycode:(CGKeyCode)code];
}
}
Expand Down

0 comments on commit 424bb4b

Please sign in to comment.