This site requires JavaScript, please enable it in your browser!
Greenfoot back
MySimpleBox
MySimpleBox wrote ...

2017/4/17

Simulating Keyboard Inputs, Using Code?

MySimpleBox MySimpleBox

2017/4/17

#
Is there a way to lets say make greenfoot act as if "g" was pressed using the Greenfoot.isKeyDown command. Basically can I simulate a keystroke without actually pressing the key?
danpost danpost

2017/4/17

#
MySimpleBox wrote...
Is there a way to lets say make greenfoot act as if "g" was pressed using the Greenfoot.isKeyDown command. Basically can I simulate a keystroke without actually pressing the key?
There is the java.awt.Robot class that contains methods like 'keyPress(String key)', 'keyRelease(String key)', 'mouseMove(int x, int y)' 'mousePress(int buttons)' and 'mouseRelease(int buttons)'. Maybe you could use it.
You need to login to post a reply.