java - Using JavaFX 8 Scene, Read Keyboard Input while running -


i have javafx 8 scene going nicely. now, while else happening, continuously check keyevent/keycode while program running. have timeline called timeline set indefinite , i've set cycle count indefinite

timeline.setcyclecount(timeline.indefinite); 

i'm looking easy method clean , won't make program choppy.

you can use keyevent listener listen when key pressed, release, typed or any of them. matter whether have infinite loop running on thread, if user presses button, listener called.

you need add listener scene , key event want listen to.

scene.addeventhandler(keyevent.key_pressed, (key) -> {       if(key.getcode()==keycode.enter) {           system.out.println("you pressed enter");       } }); 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -