GatorV Posted October 30, 2004 Share Posted October 30, 2004 Does any one know how to execute a event while a key is being pressed? for example pressing the Up key will sum a variable until the key is released, I've search google but no luck :no: Thanks in advance Link to comment Share on other sites More sharing options...
0 Dessimat0r Posted October 30, 2004 Share Posted October 30, 2004 You probably need a listener thread for best robustness. Link to comment Share on other sites More sharing options...
0 GatorV Posted October 30, 2004 Author Share Posted October 30, 2004 Thanks, that was what I needed, and Start and stop the thread when key is pressed/released no? Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted October 30, 2004 Share Posted October 30, 2004 Well, you make some class implement the KeyListener class and fill in the keyPressed, keyReleased, and keyTyped methods. Then you add a KeyListener to whatever type of GUI object you want. http://java.sun.com/docs/books/tutorial/ui...eylistener.html http://java.sun.com/j2se/1.5.0/docs/api/ja...eyListener.html Link to comment Share on other sites More sharing options...
0 GatorV Posted October 31, 2004 Author Share Posted October 31, 2004 Thanks I'll take a look at it... Link to comment Share on other sites More sharing options...
0 Winston Posted October 31, 2004 Share Posted October 31, 2004 I think that's one thing i hate about java, every single event you wire up seems to be a seperate class of it's own which implements the ActionListener, and when come time to compile you have a crap load of .class generated files for each event. Link to comment Share on other sites More sharing options...
Question
GatorV
Does any one know how to execute a event while a key is being pressed? for example pressing the Up key will sum a variable until the key is released, I've search google but no luck :no:
Thanks in advance
Link to comment
Share on other sites
5 answers to this question
Recommended Posts