Re: Map key codes to characters
Re: Map key codes to characters
- Subject: Re: Map key codes to characters
- From: Peter Edberg <email@hidden>
- Date: Sat, 23 Feb 2008 10:29:01 -0800
Christian,
The mapping from a sequence of key codes to a sequence of UniChars
(UTF16 code units, for the modern APIs) can be complex and in general
is a state machine in which the inputs include keycode, modifier
state, dead key state, and physical keyboard ID, and the outputs are
updated dead key state and a sequence of 0 or more characters. The API
that performs this mapping of keycode sequences to character sequences
is UCKeyTranslate (in the CarbonCore framework in the CoreServices
umbrella).
Consider the following simple sequence of keycode-modifier
combinations on a US key layout (assuming an ANSI or ISO physical
keyboard layout and assuming that dead key state is correctly
maintained from one UCKeyTranslate call to the next):
kVK_ANSI_E (0x0E) + option => no character output
kVK_ANSI_E (0x0E) + shift => 1 UniChar output: 0x00C9
kVK_ANSI_E (0x0E) + option => no character output
kVK_ANSI_X (0x07) + no modifiers => 2 UniChars output: 0x00B4 0x0078
In general there is no simple mapping from a given UniChar back to a
single keycode. Consider UniChar 0x00B4 above, or perhaps even 0x9053,
which requires interaction with an input method to produce.
Peter Edberg
On Feb 21, 2008, at 1:50 PM, email@hidden wrote:
------------------------------
Message: 14
Date: Thu, 21 Feb 2008 22:48:15 +0100
From: email@hidden (Christian Schmitz)
Subject: Map key codes to characters
is there a modern API which I can use to map between keys
For example giving 12 and want to get a "Q" back and for providing
"Q" I
get a 12 back.
Of course it would be nice to know the option keys.
Is that possible?
Currently I use iGetKeys, but that is failing for a lot of cases.
_______________________________________________
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