Re: Sending a keystroke
Re: Sending a keystroke
- Subject: Re: Sending a keystroke
- From: Stephane ODUL <email@hidden>
- Date: Sun, 22 Sep 2002 00:46:10 -0700
One probleme with the code is that it work right away for QWERTY
mapping only. I've tryed Dvorak keymap and the keys do not match
anymore.
Anybody know how to get the correct CGKeyCode for the current
keymapping ?
Thank you
Stephane ODUL
On Saturday, Sep 21, 2002, at 10:43 US/Pacific, email@hidden
wrote:
From CGRemoteOperation.h in the ApplicationServices.framework:
/*
* Synthesize keyboard events. Based on the values entered,
* the appropriate key down, key up, and flags changed events are
generated.
* If keyChar is NUL (0), an apropriate value will be guessed at,
based on the
* default keymapping.
*
* All keystrokes needed to generate a character must be entered,
including
* SHIFT, CONTROL, OPTION, and COMMAND keys. For example, to produce
a 'Z',
* the SHIFT key must be down, the 'z' key must go down, and then the
SHIFT
* and 'z' key must be released:
* CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)56, true ); // shift
down
* CGPostKeyboardEvent( (CGCharCode)'Z', (CGKeyCode)6, true ); // 'z'
down
* CGPostKeyboardEvent( (CGCharCode)'Z', (CGKeyCode)6, false ); // 'z'
up
* CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)56, false ); //
'shift up
*/
typedef u_int16_t CGCharCode; // Character represented by event, if
any
typedef u_int16_t CGKeyCode; // Virtual keycode for event
CG_EXTERN CGEventErr CGPostKeyboardEvent( CGCharCode keyChar,
CGKeyCode virtualKey,
boolean_t keyDown );
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.