views:

185

answers:

2

in fact i am building a virtual keyboard how can i send a keyboard event to the program through pressing a button? thanks

+7  A: 

You could use Quartz Event Servcices.
They provide CGEventCreateKeyboardEvent which allows you to emulate any physical key-press.
The API is modeled after real key events.
So you have to call "Shift" + "Character" to get an upper case letter. You also need to release keys you have pressed.
Apple's documentation contains sample code.

Update:
We are talking about Mac OS X, right? Please add some tags to your original question.

weichsel
A: 

yes we are talking about Mac OS X for sure. thanks for your reply i will work on it. many thanks

tempo
Please give the responder a green check mark for his excellent answer.
Kevin Conner