如何在Java机器人中按右Shift键?

问题描述 投票:0回答:1

您能帮我重构此代码:

public static void pressRightShift() {
    robot.keyPress(KeyEvent.VK_SHIFT);
}

请同时说明如何按向右\向左Shift键。谢谢!

java keypress robot
1个回答
0
投票

我找到了Java教程,其中包括Java WebStart示例和源代码。看起来赢家是KeyEvent.getKeyLocation()

KeyEvent.KEY_LOCATION_STANDARD
KeyEvent.KEY_LOCATION_LEFT
KeyEvent.KEY_LOCATION_RIGHT
KeyEvent.KEY_LOCATION_NUMPAD
KeyEvent.KEY_LOCATION_UNKNOWN

参考:

KeyEvent Documentation

Key Listener Demo and Source Code

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.