Can't get PhEmit to emit Key event

Hi, hopefully somebody can help me here. I’m trying to get an
application to emit a key event and the QNX documentation is rather
sparse on what exactly I’m supposed to do. I would like to use this
eventually for scripting of Photon events (pointer events and key
events) for test automation. I already have pointer events working.
Currently the code is being invoked from a button activation
callback.

Here is the code in question:

PhEvent_t event;
PhPointerEvent_t ptrEventData;
PhKeyEvent_t keyEventData;
PhRect_t rect;

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

memset( &event, 0, sizeof(event) );
memset( &ptrEventData, 0, sizeof(ptrEventData) );
memset( &keyEventData, 0, sizeof(keyEventData) );
memset( &rect, 0, sizeof(rect) );

event.type = Ph_EV_BUT_PRESS;
event.subtype = 0;
event.flags = 0;
event.num_rects = 1;
event.data_len = sizeof(ptrEventData);
event.emitter.rid = Ph_DEV_RID;
rect.ul.x = rect.lr.x = 537;
rect.ul.y = rect.lr.y = 462;
ptrEventData.buttons = Ph_BUTTON_SELECT;
ptrEventData.flags = 0;
PhEmit( &event, &rect, &ptrEventData );

delay( 80 );

event.type = Ph_EV_BUT_RELEASE;
PhEmit( &event, &rect, &ptrEventData );

delay( 1500 );

event.type = Ph_EV_KEY;
event.data_len = sizeof( keyEventData );
//rect.ul.x = rect.lr.y = 0;
//rect.lr.x = rect.lr.x = 0;
keyEventData.key_cap = 0x09;
keyEventData.key_sym = 0x09;
keyEventData.key_scan = 0x09;
keyEventData.key_mods = 0;
keyEventData.key_flags = ( Pk_KF_Key_Down | Pk_KF_Sym_Valid |
Pk_KF_Cap_Valid );
PhEmit( &event, &rect, &keyEventData );

delay( 220 );

keyEventData.key_flags = Pk_KF_Cap_Valid;
PhEmit( &event, &rect, &keyEventData );

delay( 2000 );

event.type = Ph_EV_BUT_PRESS;
event.data_len = sizeof(ptrEventData);
rect.ul.x = rect.lr.x = 841;
rect.ul.y = rect.lr.y = 717;
ptrEventData.buttons = Ph_BUTTON_SELECT;
ptrEventData.flags = 0;
PhEmit( &event, &rect, &ptrEventData );

delay( 450 );

event.type = Ph_EV_BUT_RELEASE;
PhEmit( &event, &rect, &ptrEventData );

return( Pt_CONTINUE );

A note about the scan codes. I’m not sure which type I’m supposed to
use (XT or AT) or where they’re supposed to go (key_cap, key_sym, or
key_scan). 0x09 is supposed to be the ‘8’ key.