views:

110

answers:

1

Hello,

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?

A: 

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".

hacksteak25
It would be nice to know how you solved this at the end :-)
Grodriguez
I am not sure if you really want to know it (ugly, dirty, much code), but ^^I know use Synergy (http://synergy-foss.org/). The synergy client connects to my java instance. The java instance then sends synergy data packets. I inspected the synergy traffic with wireshark because I found no protocol specs... The main problem is that I have to map EVERY key or mouse event to a synergy event (found no automatic solution)... and there are many keys on a keyboard ;)Still found no Java-based solution.
hacksteak25
Interesting. Thanks a lot.
Grodriguez