...
I want the program to type the strings with
Robot r = new Robot();
r.keyPress( keyCode );
r.keyRelease( KeyCode );
The code looks like you're trying to fire an event.
Just have a look at this
Key Press ---> Event Fired ---> Something happens
You are trying to get the key pressed like this
Event Fired ---> Something happens
Jumping to the second step won't make the first step happen. Get my drift?