0

Keyboard input

So i heard that you have to use KeyListener and KeyEvent. Can someone paste in the comments an example? For ex. printing out a letter that I just typed

12th Jul 2018, 2:25 PM
StanisƂaw
StanisƂaw - avatar
1 Answer
0
Depends on whether you are wanting to listen for global keyboard events or keyboard events when the application is in focus. You can listen for global key presses but its through an external library, however you can listen for application keystrokes via the events tab on the main form. In JavaFX form designer click the main form and go to the properties tab on the eight and click events, then find an event basically named onKeyPress or something, then double click it and in there you can pull the key event data from the custom arguments parameter that is passed through the method that is generated. Two things to note: I haven't done JavaFX in about a year now and primarily work with C# but the steps should be similar. If this example is a little much or no adequate for you, just search on YouTube "listen for keyevents JavaFX" and you'll get plenty of results. Good luck, hope this helped.
13th Jul 2018, 4:14 AM
John
John - avatar