On Mac, KeyEvent.getKeyText should return the unicode character (e.g. “\u2318” for the command symbol) for proper use with menu items and accelerators. I can confirm that VK_META returns “\u2318” on my Mac, which is then printed to the console as ‘?’. VK_SPACE also turns into a ‘?’.
It’s pretty useless for debugging and practical purposes, though… Especially games with limited character sets for their bitmap fonts.
Since there are so many keys that would be displayed as “?” on Mac (alt, control, shift, escape, tab, left, up, etc) I would suggest rolling your own KeyEvent-to-text, e.g.
http://www.java-gaming.org/?action=pastebin&id=247
(Ideally much of that would be put into a properties file for localization…)
[quote]VK_SPACE has always, is always, and will always be 32. OP might be from another language where 32 is commonly used so it’s fine for this case.
Also, the KeyEvent keycodes for 0-9 and A-Z do correspond to their ASCII counterparts.
[/quote]
As stated in the KeyEvent javadocs:
WARNING: Aside from those keys that are defined by the Java language (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_ constants. Sun reserves the right to change these values as needed to accomodate a wider range of keyboards in the future.