Although this is an old question, I will post my answer if it helps someone later.
I recently ran into the same problem. I called keyPress and keyRelease right after the other for each of the left, right, up and down keys, based on some external input. I tried a bunch of games, but Robot keystrokes didn't work in any of them. When I tried the same code with the cursor in a text file, the cursor moved correctly.
The problem was that games usually require continuous keystrokes, so the combination of keyPress + keyRelease has no effect. So I fixed the problem by calling keyRelease in the opposite direction for each arrow key.
For example, if you need to press the left arrow key, I call
keyRelease(KeyEvent.VK_RIGHT);
keyPress(KeyEVent.VK_LEFT);
This holds the left key down until the right arrow key is finally pressed. There are better ways to do this by tracking the last keystroke, etc., but this method works fine.
Sameer
source share