Frage

I created Robot class in JAVA but there is a issue robot.keyPress(KeyEvent.VK_AT) have to press -> '@' -> at

But it presses 'q' <-> 'Q'

What should i do to robot press '@' symbol ?

War es hilfreich?

Lösung

On my keyboard, the @ key requires combining the Shift and 2 keys; others may vary. The test image below was produced by adding the following to this example.

Addendum: As noted in comments by @neat159, the host OS keyboard control panel setting must match the intended keyboard layout being tested.

r.keyPress(KeyEvent.VK_SHIFT);
r.keyPress(KeyEvent.VK_2);
r.keyRelease(KeyEvent.VK_2);
r.keyRelease(KeyEvent.VK_SHIFT);

image

Andere Tipps

Have you tried using the constant KeyEvent.VK_AMPERSAND ?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top