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. :(

[341 byte] By [theperson8a] at [2007-10-2 21:11:18]
# 1
I'm afraid that you're trying to do the impossible. You have two options:1. Use a GUI component.2. Use native code.For option 2 there are existing third-party libraries you could look into, such as http://sourceforge.net/projects/javacurses/ .
YAT_Archivista at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...
# 2

> 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.

prometheuzza at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...
# 3
nevermind, problem solved.thanks for your guidance!Message was edited by: theperson8
theperson8a at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...
# 4
Do tell us your solution. Imagine the other poor folks that come here looking how to do this, find this thread and still have no answer to the question.
marlin314a at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...
# 5
Hi...I am stuck with the same problem, that you have mentioned.Can you please tell me the solution that you found for this problem.Thanks,Ashish
eragarwala at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...
# 6

> 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.

CaptainMorgan08a at 2007-7-13 23:57:29 > top of Java-index,Other Topics,Algorithms...