How do i use a variable to press a key with robot class

ok,
here is an example:

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent; 

Robot robot;
String  keyString="hello world";
void setup() {

  size(100, 100);
  try { 
    robot = new Robot(); 
  } 
  catch (AWTException ex) {
    System.out.println(ex.getMessage());
  }
  frameRate(1);
}

void draw() {
  sendKeys(robot, keyString);
}

void sendKeys(Robot robot, String keys) {
  for (char c : keys.toCharArray()) {
    int keyCode = KeyEvent.getExtendedKeyCodeForChar(c);
    if (KeyEvent.CHAR_UNDEFINED == keyCode) {
      throw new RuntimeException(
        "Key code not found for character '" + c + "'");
    }
    robot.keyPress(keyCode);
    robot.delay(100);
    robot.keyRelease(keyCode);
    robot.delay(100);
  }
}

run the sketch then go back to processing ide