• 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: Detect Keyboard Layout for CGKeyCodes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detect Keyboard Layout for CGKeyCodes


  • Subject: Re: Detect Keyboard Layout for CGKeyCodes
  • From: Joe Turner <email@hidden>
  • Date: Wed, 19 Aug 2009 21:02:19 -0500

Hey,

This is not *exactly* what I would like to achieve. Basically, what I would like to do is the reverse: I would like to convert a string into a CGKeyCode. Like on a US keyboard, I would input the string "a" and get returned the CGKeyCode 0. This would be extremely straight-forward (just a matter of including Events.h from HIUtilites), except that all the constants only stand true for US keyboards. So, I would like to be able to convert based on the keyboard they have, so the right key gets a simulation of a click.

Or, maybe there's a better way to do this than CGEvents? I just need it to be universal–This app is a background app, so the keystroke needs to be able to be inserted anywhere.

Cheers,

Joe Turner
On Wednesday, August 19, 2009, at 07:30PM, "Harry Jordan" <email@hidden> wrote:
>I've not used CGEvents much.. (Once upon a time, hopefully never
>again) but if I remember rightly CGKeyCodes are equivalent to NSEvent
>keyCodes*. If not you can easily convert between the two using: +
>(NSEvent *)eventWithCGEvent:(CGEventRef)cgEvent.
>
>Have a look at this: http://inquisitivecocoa.com/2009/04/05/key-code-translator/
>  for my version of what I think your trying to achieve. Be warned,
>there are a few gaps in my implementation (like F numbers for
>instance), but that shouldn't be that hard to add.
>
>Harry Jordan
>http://inquisitivesoftware.com/
>
>On 19 Awst 2009, at 18:40, Joe Turner wrote:
>
>> Hey,
>>
>> I've got an application that basically simulates a keyboard using
>> CGEvents with CGKeyCodes. However, because CGKeyCodes only map the
>> position of the key on a keyboard, and not the actual key, I've run
>> into some issues. Is there an easy way to detect the type of
>> keyboard they have, and convert a CGKeyCode from a standard US
>> keyboard to whatever keyboard they have?
>>
>> Any help would be much appreciated! :)
>>
>> Joe
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Detect Keyboard Layout for CGKeyCodes
      • From: Harry Jordan <email@hidden>
References: 
 >Detect Keyboard Layout for CGKeyCodes (From: Joe Turner <email@hidden>)
 >Re: Detect Keyboard Layout for CGKeyCodes (From: Harry Jordan <email@hidden>)

  • Prev by Date: Re: FYI - new debug & profile libraries are out: Installer Refuses
  • Next by Date: Re: devil of a time with an NSImageView
  • Previous by thread: Re: Detect Keyboard Layout for CGKeyCodes
  • Next by thread: Re: Detect Keyboard Layout for CGKeyCodes
  • Index(es):
    • Date
    • Thread