• 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
converting a characer to a keycode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

converting a characer to a keycode


  • Subject: converting a characer to a keycode
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 8 May 2009 16:36:40 -0700

i would like to convert a character to its corresponding virtual keycode.

the why: i allow users to specify keyboard equivalents for menu items (in a manner similar to xcode key binding preferences). for reasons i don't understand it works better use unshifted characters for the shifted numeric keys. ie, command-shift-1 works for me, whereas command-! (command-exclamation mark) does not.

additonally, my app is fully scriptable and i allow the user to specify the keyboard shortcut via an applescript. thus, i would like to convert a script specification of command-exclamation mark to command-shift-1 (command-shift-one).

the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character.

and while this is certainly doable, it feels awfully clumsy (and potentially slow).

is there a better way?

thanx,
ken
_______________________________________________

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


  • Prev by Date: Re: Getting the private IP
  • Next by Date: Re: converting a characer to a keycode
  • Previous by thread: Re: Renaming a file repositions icon in Finder
  • Next by thread: Re: converting a characer to a keycode
  • Index(es):
    • Date
    • Thread