Help with keylistener
For the life of me I can't understand how to implement a keylistener without using any gui elements. I am writing a text-based rpg and just need to check to see which keys are being held down at any given moment.
if anyone could offer me some sample code i'd be immensely grateful. None of my attempts thus far have worked. :(
> For the life of me I can't understand how to
> implement a keylistener without using any gui
> elements. I am writing a text-based rpg and just need
> to check to see which keys are being held down at any
> given moment.
>
> if anyone could offer me some sample code i'd be
> immensely grateful. None of my attempts thus far have
> worked. :(
As far as I know, you can't do that with pure Java. You need some sort of Component to add a KeyListener to. What you can do is create some sort of GUI-prompt yourself to add a KeyListener to. For details on that, I suggest posting a question in the Swing section of the forum: http://forum.java.sun.com/forum.jspa?forumID=57
Good luck.
> I am stuck with the same problem, that you have
> mentioned.
> Can you please tell me the solution that you found
> for this problem.
Read through the thread. Also, I have heard that you can create an invisible window over the entire computer screen and add a listener to that.