Question

I want to use the java.awt.Robot class to implement a virtual keyboard. I am wondering if there is a way to send the keycode WITH the key location (left or right) using the keyPress(int) method. If you add a KeyListener to an awt Element, a KeyEvent triggered by ctrl or shift has an information if it was the left or right button.

The Docs tells:

Key codes that have more than one physical key associated with them (e.g. KeyEvent.VK_SHIFT could mean either the left or right shift key) will map to the left key".

But is there really no way to send a right shift pressed? Some applications (eg. VirtualBox) need those right buttons (sure, you might configure those applications, but thats no option for a virtual keyboard).

So... is there a way to do this with the Robot class? Is there an alternative way to send more specific key events in Java?

Was it helpful?

Solution

After more searching I currently think that java.awt.Robot might be not the right choice. There are known problems sending special keys like german umlauts that has no key code assigend in the jvm.

So I answer this question myself with "There is no way to do it with the Robot class".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top