I want to have a method that would click a certain key

public void pressKey ( KeyEvent keyName ) {  // what class must keyName belong to ? 
    this.robot.keyPress(KeyEvent.keyName);
    this.robot.keyRelease(KeyEvent.keyName);
    Thread.sleep(100);
}

It should work as a shorcut for example

pressKey(VK_ENTER);

But I tried to look up those VK_ codes and still do not know to what class do the keycodes belong ?

有帮助吗?

解决方案

The VK_ values are static fields in the KeyEvent class.

Here is a list of all the values.

其他提示

The VK_ codes are of type int.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top