File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes KeyListner for non-awt-swing class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "KeyListner for non-awt-swing class" Watch "KeyListner for non-awt-swing class" New topic

KeyListner for non-awt-swing class

Liming Xu

Joined: Jan 22, 2002
Posts: 19
Hi all, I have a bean class and I want to register it so that it's able to do something when a Keyboard event is fired. It's not a AWT/SWing componet...because I want it to be able to get keyboard stroke without providing any visual components. How do I do that? Thanks a lot.
Liming Xu

Joined: Jan 22, 2002
Posts: 19
BTW, mabye it'll be more clear this way. We are writing an application for a Scanner utitly(web based). Many scanner on the market connects to PS/2 keyboard port, so when the clients scan using this kind of Scanner, we want to be able to read the keyboard characters behind the background by invoke a bean class. The web developer will call my bean from a page, and my bean is suppose to sit in the background and read keyboard events. Obviously, I can't ask ppl to open a command prompt whenver the user reach that webpage, (btw, user is on serverside as well), so reading input from command prompt is not going to help.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
All of the events in Java are in the AWT and are intended for GUI interactions. If you want to watch for stuff outside of a Java GUI you are going to need to use some operating system level operations, which of course will prevent it from being platform independant.
The best that I can suggest is to see how the Java events are handled in the AWT and "borrow" some of that code to use as a basis for what you need.
and Lim,
Please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Liming Xu

Joined: Jan 22, 2002
Posts: 19
Thanks Cindy.
I agree. Here's the link:
subject: KeyListner for non-awt-swing class
It's not a secret anymore!