views:

34

answers:

3

Hi. Can someone please tell me how to determine the unicode character point of a multi-key combination that includes the "command" key? For example, if a user presses the "command" key and "1" key on the keyboard at the same time, what is the unicode character representation for that?

Maybe I'm searching on the wrong thing, but I am not able to locate this in the character maps, keyboard references, or unicode tables I find. I can sort out other key combinations (e.g. shift-1) as there is an obvious character output of "!" that I can look up and find that it is U+0021. When I go to character maps or applications the command key always seems to take an action rather than output a character result to screen.

My app is for iOS, which I would expect to be the same as Mac OS X in terms of the unicode code point. All of the iOS APIs that provide access to the keyboard see it as a source of Unicode characters. Thus the reason I am trying to detect keystrokes this way.

Thanks.

A: 

Simple answer: no.

You haven't told us what sort of computer you are using. Mapping a key press to a Unicode code point is operating system specific, and then it depends on the locale that is active.

bmargulies
My app is for iOS, which I would expect to be the same as Mac OS X in terms of the unicode code point.
DenVog
+2  A: 

Keyboard codes are basically independent of character codes.

While (as you mention) many keys have standard mappings to standard ASCII codes, it is up to the application to decide what to do with them.

Some input API's may be widely used on a particular OS, and some applications (e.g., terminal emulators) may be used as a common input method for a class of tasks, but there is no universal standard.

Obligatory wikipedia link for Unicode input.

comingstorm
I am developing the application, so I can ultimately decide what to do with it. Though I have to be able to detect it first. My app is for iOS, which I would expect to be the same as Mac OS X in terms of the unicode code point.
DenVog
All of the iOS APIs that provide access to the keyboard see it as a source of Unicode characters.
DenVog
A: 

You can't. There simply are no Unicode codepoints that correspond to Command + some-other-character.

The same is true of Shift, by the way. The fact that your computer happens to map certain combinations to certain Unicode codepoints does not imply that Unicode specifies such mappings, or that mappings exist for every combination of keys, or that those mappings are the same for everyone else. I use two keyboards every day; one of them maps Shift+3 to #, the other maps it to £. This is decided by the operating system, not by Unicode. If you tried to detect a Shift+3 keypress by listening for #, your program would seem to me to be broken half the time.

This is a perfect example of an XY question. You don't really care about Unicode -- what you really want to know is how to detect keypresses with the Command modifier on iOS. You should just have asked how to do that! There is probably an API that does exactly what you need that you have simply missed, because you were concentrating on your assumption that the solution would involve Unicode -- and there are probably numerous iOS experts who have not bothered to read this question at all, because they thought your problem related to Unicode rather than iOS.

Porculus
I do not believe this to be true for two reasons: 1. Apple has specifically responded that "All of the APIs that provide access to the keyboard see it as a source of Unicode characters and nothing more." 2. There are unicode equivalents for at least some key combinations, as I referred to in my example for Shift-1 and this Stack Overflow post. http://stackoverflow.com/questions/3199635/iphone-ipad-keyboard-shortcuts
DenVog
Sorry if I did not do a good job of articulating things in my initial post.
DenVog