title: CGEventPost - possible bug when simulating keyboard events?
body: <p>I have a very simple chunk of code that is designed to simulate keyboard events.  The simple example below should type "Cz" - the shift key goes down, the c key goes down, c comes up and shift comes up.  Then the z key goes down and up.</p>
  
  <p>It seems that sometimes the order gets muddled though.  When I create a timer to call this routine every second, the output should be CzCzCzCz.... But here's what I get:</p>
  
  <p>CZcZCZCzczCzczCzczCZCZCzCz</p>
  
  <p>I'll run it again:</p>
  
  <p>CzCzCzCzCZCzCZCzCZCzCZCzCZCzCzCz</p>
  
  <p>Different.  And equally wrong.</p>
  
  <p>The code:</p>
  
  <pre><code>e1 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)56, true);
  CGEventPost(kCGSessionEventTap, e1);
  CFRelease(e1);
  e2 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)8, true);
  CGEventPost(kCGSessionEventTap, e2);
  CFRelease(e2);
  e3 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)8, false);
  CGEventPost(kCGSessionEventTap, e3);
  CFRelease(e3);
  e4 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)56, false);
  CGEventPost(kCGSessionEventTap, e4);
  CFRelease(e4);
  
  e7 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)6, true);
  CGEventPost(kCGSessionEventTap, e7);
  CFRelease(e7);
  e8 = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)6, false);
  CGEventPost(kCGSessionEventTap, e8);
  CFRelease(e8);
  </code></pre>
  
  <p>Is there something I'm missing in how to implement the keydown and keyup for the shift key?    I think this might be a bug - where would I report it?</p>