Hi,
I'm writing an app where I need to simulate key press events on a mac, given a code that represents each key. It seems I need to use the CGEventCreateKeyboardEvent
function to create the event. The problem is that this function needs a mac keycode, and what I have is a code that represents the specific key. So, for example, I recieve:
KEY_CODE_SHIFT
or KEY_CODE_A
- these are both numeric constants defined somewhere.
I need to take these constants and turn them into CGKeyCode
values.
My current attempt uses code similar to this SO question. The problem is that it only works for printable characters. If all else fails, I'm not above hard coding the conversion, but that would mean that I'd need a table of possible CGKeyCode values, which I have not yet been able to find.
Any ideas?