View Full Version : Coding a custom virtual keyboard under xcode

Dec 5, 2010, 08:26 PM
I've registered here hoping to receive more answers. Apple discussions proved to be a dead end so here it goes. My question is this. I have created a layout in IB for a virtual keyboard. It contains 5 rows of buttons and I want to assign a global character entry to each button. i.e. When a button is pressed, it outputs a character to any text box within OS X. So far the closest I've come to something that is even remotely related is the use of kVK's (Virtual Keycodes) in the HIToolBox framework (Events.h). Please don't tell me it's not possible because there are a stack of soft keyboards up for download. It's just that none of them appeal to what I want. Thanks in advance.

Dec 5, 2010, 09:32 PM
It's indeed possible, os x already includes a keyboard viewer that does exactly what you describe. I'm not sure how you would create your own though.

Dec 5, 2010, 09:52 PM
I'd suspect that the character viewer uses CGEventPost() or CGEventPostToPSN()

So lookup CGKeyCode's and CGEventRef and CGEventCreateKeyboardEvent()