Re: CGPostKeyboardEvent() to post Unicode;;;
Re: CGPostKeyboardEvent() to post Unicode;;;
- Subject: Re: CGPostKeyboardEvent() to post Unicode;;;
- From: Matt Budd (Madentec) <email@hidden>
- Date: Thu, 23 Sep 2004 11:53:14 -0600
Thanks for the reply John....hopefully that will be fixed in a Panther
upgrade (not a Tiger only fix)?
As a work around, lets say we restricted the problem to just emulating
characters that are generate-able by the keyboard (for example, say we
want to send the letter 'q' to an application). Then if they are
running an English keyboard layout, that would be keycode 0xC. Sending
keycode 0xC on a French layout, however, ends up typing the letter 'a'.
To send the letter 'q' properly for a French keyboard layout, we'd have
to send the keycode 0x0.
Letter English Keycode French Keycode
===== ============= ============
'a' 0x0 0xC
'q' 0xC 0x0
So since I can't simply send the unicode 'a' or 'q' to an application,
how do I go about figuring out what the proper keycode for that given
character is (based on the current keyboard layout). I can use the
Keyboard Layout Services (KLGetCurrentKeyboardLayout() and
KLGetKeyboardLayoutProperty()), but this only gives me the
opposite...it tells me the what the character will be for a given
keycode; character = func(keycode). I would like the inverse; keycode =
func(character), since I can only post keycodes.
I suppose I could iterate through all possible keycodes (0 to 127?) and
construct a reverse lookup table, but that would be a pretty large and
sparse data structure (about 512KB since there are 65536 unicode
characters and each entry would be 8 bits (for a keycode)). Is there a
better supported way to get the keycode for a given unicode character,
based on the current keyboard layout?
- Matt
On Sep 23, 2004, at 9:41 AM, John Louch wrote:
Nope. Though we have this a bug request already for the accessibility
API.
Thanks,
jl
Hey David,
I don't mind help from competition if you don't mind helping the
competition ;) .
The problem I am thinking of is that say someone has a Japanese
keyboard and they want to type a Japanese unicode character, say
0x4586
(actual char: '䖆')....they do this through some certain keystrokes.
Then they move to a US keyboard and still want to send that same
Japanese unicode character. Now there is no way to generate this on a
regular US-101 or 102 keyboard (unless you have the Unicode Hex Input
method on and type "Option+4+5+8+6" (like I did to generate the above
character)).
So basically I would want to instead of sending keystrokes to just
send
unicode characters directly. Is there anything like that for OS X?
- Matt
On Sep 23, 2004, at 1:10 AM, David Niemeijer wrote:
Hi Matt,
At 11:55 AM -0600 22/9/04, Matt Budd (Madentec) wrote:
I know that CGPostKeyboardEvent() can be used to simulate keystrokes
(by providing the keycode), but what do I use if I just want to send
an application a unicode character (that might not be enterable
directly by the keyboard and a matching keycode)?
If you do not mind some help from the competition: You need to send
all the keystrokes that would be needed on the physical keyboard to
generate that unicode character. For example, to generate an e with
an
accent, you would send "option-e" followed by "e".
Hope this helps,
david.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--------------------------------------------------
John Louch Internet #: email@hidden
(805) 546 0216
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden