Hello list folk - I'm trying to print out strings representing various keyDown events I receive. Using OS 10.6.2.

It looks as though this was possible back in the classic days ( http://developer.apple.com/legacy/mac/library/documentation/mac/Toolbox/Toolbox-78.html ), however obviously that doesn't do much for me here.

Obviously the characters / charactersIgnoringModifiers strings I get with the event works great for alphanumeric stuff, however I'm also interested in things like function keys & the like. And up to this point I'm afraid that all I've been able to find on this makes me think I'm going to have hard-code a lookup table to translate non-alphanumeric key presses, which has me freaked out, since I've no idea what keyboards are like in other locales.

So far the two approaches I've seen are as follows:

Approach #1: Map every keyCode you can think of (example: the keyStringForKeyCode method in http://ritter.ist.psu.edu/projects/RUI/macosx/rui.c ) :

   switch (keyCode) {
       case 0: return("a");
       case 1: return("s");
       ...
       case 96: return("F5");
       ...

Approach #2: Get what you can via UCKeyTranslate, and then 'fill in the blanks' with a lookup table for non-alphanumeric stuff (example: http://inquisitivecocoa.com/2009/04/05/key-code-translator , which looks like it builds off a patched version of http://rogueamoeba.com/sources/HotKeysLib3.zip )

Prior threads by people in the know ( http://www.cocoabuilder.com/archive/cocoa/101991-key-codes-and-characters-in-nsevents.html ) further state that developer-created lookups are a fact of life in this area, but I'm reely hoping they are not ...

Questions:

1) Is there a programmatic method to get strings like this (I'm guessing not)

2) Is a F1 key the same on all keyboards (if so then my worries about the lookup table are a non-issue)

3) Are there any keys typical in other places that don't exist on a 'standard' North American keyboard ? (if so heaven help me)

Thanks all for any insight you may be able to provide - Dave




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to