MattGP Posted June 29, 2017 Share Posted June 29, 2017 Title. How do you simulate the space key being held down? Thanks! Quote Link to comment Share on other sites More sharing options...
d0zza Posted June 29, 2017 Share Posted June 29, 2017 (edited) There's a keyboard section in the API. getKeyboard().pressKey(int keyCode) When you want to release the key do: getKeyboard().releaseKey(int keyCode) Edited June 29, 2017 by d0zza Quote Link to comment Share on other sites More sharing options...
Doflamingo Posted June 29, 2017 Share Posted June 29, 2017 Where do you grab the key-code values? I'm used to using javaFX for my applications, javaFX has an enum type KeyCode. Type methods are easy because they parameterize char/String variables. Quote Link to comment Share on other sites More sharing options...
Lemons Posted June 29, 2017 Share Posted June 29, 2017 java.awt.event.KeyEvent contains the key codes, such as KeyEvent.VK_SPACE would be space. https://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html Quote Link to comment Share on other sites More sharing options...
MattGP Posted June 29, 2017 Author Share Posted June 29, 2017 8 hours ago, d0zza said: There's a keyboard section in the API. getKeyboard().pressKey(int keyCode) When you want to release the key do: getKeyboard().releaseKey(int keyCode) press key only presses the key once instead of holding it down when I did some tests.. is there some other way? Quote Link to comment Share on other sites More sharing options...
d0zza Posted June 30, 2017 Share Posted June 30, 2017 8 hours ago, MattGP said: press key only presses the key once instead of holding it down when I did some tests.. is there some other way? Hmm I'm not sure then, but why are you trying to simulate the space key being held down? If it's for when you're talking to npcs look into the dialogue section of the API Quote Link to comment Share on other sites More sharing options...
MattGP Posted June 30, 2017 Author Share Posted June 30, 2017 28 minutes ago, d0zza said: Hmm I'm not sure then, but why are you trying to simulate the space key being held down? If it's for when you're talking to npcs look into the dialogue section of the API Well for 1) tutorial island is always in dialogue so I thought it might be best to make my own complete dialogue and 2) a normal player would simply hold down space bar to go through dialogue! Quote Link to comment Share on other sites More sharing options...