Use KeyEvent.getExtendedKeyCodeForChar()
:
final String string = "camera";
for(char character : string.toCharArray()){
robot.keyPress(KeyEvent.getExtendedKeyCodeForChar(character));
robot.keyRelease(KeyEvent.getExtendedKeyCodeForChar(character));
}
If you need to concatenate the "camera" value with a number (or another string), there is this question that already addresses the subject.
final int MAX = 5;
final Robot robot = new Robot();
for(int i = 1; i <= MAX; i++){
final String string = "camera" + i;
for(char character : string.toCharArray()){
robot.keyPress(KeyEvent.getExtendedKeyCodeForChar(character));
robot.keyRelease(KeyEvent.getExtendedKeyCodeForChar(character));
}
// só para pular linha no output, não são necessárias as duas linhas abaixo.
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
output:
camera1
camera2
camera3
camera4
camera5