Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Using keyboard instead of mouse

+16 votes
is there a method to make the components   inside my panel( car )  to follow my keyboard instructions ( up , down , right , left ) instead of the mouse ?
asked Oct 17, 2016 in CSC 211 (F16) by Samih Sghier (100 points)

2 Answers

+4 votes
Best answer
Yes, I posted some example code for getting Keyboard input on Moodle, underneath the Nifty Project assignment, and the new sample code for doing images & sounds.

Hope that helps...
answered Oct 17, 2016 by Forrest Stonedahl (100 points)
selected Oct 17, 2016 by Samih Sghier
+1 vote
You can use panel.getKeyboardInput(), which will return a string of whatever you pressed. The strings returned for pressing arrows are "Up", "Down", "Left", "Right".

If you ever need to do something and your aren't sure how to do it, it is always useful to look at what pops up in eclipse after you type panel.whatever
answered Oct 17, 2016 by Ryan Philp (100 points)