In this case the reflection API may be useful:
for (int i = 0; i < 9; i++) {
try {
final Field field = KeyEvent.class.getDeclaredField("VK_" + i);
r.keyPress((int) field.get(KeyEvent.class));
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}