simulate backspace key with java.awt.Robot

后端 未结 2 1803
眼角桃花
眼角桃花 2020-12-04 02:37

There seems to be an issue simulating the backspace key with java.awt.Robot.

This thread seems to confirm this but it does not propose a solution.

2条回答
  •  借酒劲吻你
    2020-12-04 02:50

    The Backspace functionality does not work as expected. I added a Shift key with the Backspace and it works fine for me, here is the pseudo-code for it.

    robot.keyPress(KeyEvent.VK_SHIFT);
    robot.keyPress(KeyEvent.VK_BACK_SPACE);
    robot.keyRelease(KeyEvent.VK_BACK_SPACE);
    robot.keyRelease(KeyEvent.VK_SHIFT);
    

    This does not seem to work for the Delete key though.

提交回复
热议问题