I am using Java Robot class to send keyevents. I tried robot.keyPress()
function. But I could not figure out how to send CTRL+z keyEvent.
Asked
Active
Viewed 2.1k times
12

Ripon Al Wasim
- 36,924
- 42
- 155
- 176

sayem siam
- 1,281
- 3
- 13
- 26
1 Answers
18
robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_Z)
// CTRL+Z is now pressed (receiving application should see a "key down" event.)
robot.keyRelease(KeyEvent.VK_Z)
robot.keyRelease(KeyEvent.VK_CONTROL)
// CTRL+Z is now released (receiving application should now see a "key up" event - as well as a "key pressed" event).

ziesemer
- 27,712
- 8
- 86
- 94