• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sending a keystroke
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Sending a keystroke (From: email@hidden)

  • Prev by Date: Effects of editing Info.plist
  • Next by Date: Re: NSAttributedString and HTML
  • Previous by thread: Re: Sending a keystroke
  • Next by thread: Re: Sending a keystroke
  • Index(es):
    • Date
    • Thread