aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes to identify keypressed event in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "to identify keypressed event in java" Watch "to identify keypressed event in java" New topic
Author

to identify keypressed event in java

Gayani Kanchana
Greenhorn

Joined: Mar 27, 2007
Posts: 19
In my program i want some task to run when user pressed any key.i am running my program in console mode.how to identify when user press any key.please help.

thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8895
    
    8

Can't be done in the J2SE. The stream from the console is buffered, so we only get data after a line feed (i.e. after the user presses "enter").
I've done it using JNI, but really, if you want a fully-featured GUI, use AWT or Swing.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
sudhakar ananth
Ranch Hand

Joined: Feb 02, 2007
Posts: 68
can you tell how to do in swing
it really needed to me...
bye...
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8895
    
    8

The Java Tutorial: How to write a Key Listener
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to identify keypressed event in java