代码在javafx.scene.input.KeyCode中定义为常量。
使用玻璃机器人,您可以使用不推荐使用的方法impl_getCode
:
Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
robot.keyPress(KeyCode.A.impl_getCode());
您也可以使用FXRobot,它以KeyCodes作为参数:
FXRobot robot = FXRobotFactory.createRobot(scene);
robot.keyPress(javafx.scene.input.KeyCode.A);