开发者

Java awt.Robot: send key with position for eg. right shift or right ctrl

开发者 https://www.devze.com 2023-01-14 22:48 出处:网络
I want to use the java.awt.Robot class to implement a virtual keyboard. I am won开发者_开发知识库dering if there is a way to send the keycode WITH the key location (left or right) using the keyPress(i

I want to use the java.awt.Robot class to implement a virtual keyboard. I am won开发者_开发知识库dering 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消