def _specialKeyEvent(key, upDown):
assert upDown in ('<STR_LIT>', '<STR_LIT>'), "<STR_LIT>"<EOL>key_code = special_key_translate_table[key]<EOL>ev = AppKit.NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(<EOL>Quartz.NSSystemDefined, <EOL>(<NUM_LIT:0>,<NUM_LIT:0>), <EOL><NUM_LIT> if upDown == '<STR_LIT>' else <NUM_LIT>, <EOL><NUM_LIT:0>, <EOL><NUM_LIT:0>, <EOL><NUM_LIT:0>, <EOL><NUM_LIT:8>, <EOL>(key_code << <NUM_LIT:16>) | ((<NUM_LIT> if upDown == '<STR_LIT>' else <NUM_LIT>) << <NUM_LIT:8>), <EOL>-<NUM_LIT:1> <EOL>)<EOL>Quartz.CGEventPost(<NUM_LIT:0>, ev.CGEvent())<EOL>
Helper method for special keys.

    Source: http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac