Re: converting a characer to a keycode
Re: converting a characer to a keycode
- Subject: Re: converting a characer to a keycode
- From: Greg Guerin <email@hidden>
- Date: Fri, 8 May 2009 16:50:01 -0700
ken wrote:
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?
Create the inverse mapping once, e.g. in an NSDictionary, then use
that mapping thereafter, instead of searching repeatedly.
This assumes there is an unambiguous inverse mapping, which ain't
necessarily so. For example, a keyboard with a numpad has duplicate
key legends for all numpad keys. I think these numpad keys have
different keycodes than the keys in the main alphanum layout. So
given a character like "1" (or "*", "=", etc.) it's not possible to
reverse it to a single unique keycode.
-- GG
_______________________________________________
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