Skip to content

Instantly share code, notes, and snippets.

@asus4
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asus4/d094eb255442dd15843f to your computer and use it in GitHub Desktop.
Save asus4/d094eb255442dd15843f to your computer and use it in GitHub Desktop.
Create Mac native key events ref: http://qiita.com/asus4/items/a2517aed8dc7e4773c34
- (void) keyEmulate {
CGEventRef keyup, keydown;
keydown = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)40, true);
keyup = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)40, false);
CGEventPost(kCGHIDEventTap, keydown);
CGEventPost(kCGHIDEventTap, keyup);
CFRelease(keydown);
CFRelease(keyup);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment