Domanda

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 ?

È stato utile?

Soluzione

The VK_ values are static fields in the KeyEvent class.

Here is a list of all the values.

Altri suggerimenti

The VK_ codes are of type int.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top