If you intend on generating input events (key presses, mouse clicks, etc) at a low level (so that normal apps will respond to them as if the user had caused them to happen), you could look in to "event taps."
This API was introduced in 10.4. There were a lot of bugs in this API 10.4.0.
It was a lot better in 10.4.10 (that's the last time I used it), though there were still some significant bugs.
I used it to create a daemon that converts enter key presses and releases to right-mouse button presses and releases.
I remember that one of the bugs I ran in to was that when I created a new event, the input system of the mac hung (until reboot). I thought I had followed the documentation and tried a few things to resolve it but without success (For my purposes, I realized that I didn't have to create a new event, just repurpose the existing one, so ultimately I just worked around the problem). It seems like you are mostly concerned with creating new events, though, so be prepared. Maybe I was doing something wrong and you will figure it out where I didn't, or maybe it was a bug and Apple fixed it.
The other route to go is to create a virtual keyboard driver and have it generate events. This is even lower level than the event taps and would work if event taps aren't up to the task. In that case, you'll want to go though the docs or the IOKit. This will be a bunch more work than the event taps, though. If you go this way, you might want to look for an opensource project that implements something like this to give you a leg up.