Getting a KeyEvent from a char?

Hello,

Basically what I would like to do is send a string to my method, slice it up into characters, and convert these characters to KeyEvent, and one at a time send them to the keyboard via Robot.

For example, I want my input to be this:

"HELLO"

and my method will do the following:

robot.keyPress(KeyEvent.VK_H);

robot.keyPress(KeyEvent.VK_E);

robot.keyPress(KeyEvent.VK_L);

robot.keyPress(KeyEvent.VK_L);

robot.keyPress(KeyEvent.VK_O);

Unfortunately, I can't exactly fathom how this is possible. I noticed that you can go to the other way - converting from the KeyEvent to the letter with the KeyEvent.getKeyText method - but there is no method that I can find that will produce the desired results.

Thanks in advance for any help.

[808 byte] By [rlr2a] at [2007-11-27 10:19:13]
# 1

Check out javax.swing.KeyStroke. You can conviently get the keyCode from that class

ICE

icewalker2ga at 2007-7-28 16:56:20 > top of Java-index,Java Essentials,Java Programming...