How do you get the VK code from a char that is a letter? It seems like you should be able to do something like javax.swing.KeyStroke.getKeyStroke(\'c\').getKeyCode()<
Maybe this ugly hack:
Map keyTextToCode = new HashMap(256);
Field[] fields = KeyEvent.class.getDeclaredFields();
for (Field field : fields) {
String name = field.getName();
if (name.startsWith("VK_")) {
keyTextToCode.put(name.substring("VK_".length()).toUpperCase(),
field.getInt(null));
}
}
keyTextToCode would then contain the mapping from strings (e.g. "A" or "PAGE_UP") to vk codes.