keyboard hit

Posted on 2005-04-18
Last Modified: 2012-05-07
Been all over deja and the question is always left hanging.

I've tried various io classes to try and recognize a keyboard press
inside a java console program.  All seem to need the flush of
a 'ENTER' key.

Is there a way to recognize a keyboard hit?


while (!class.ready()) doesn't work
Question by:hank1
    LVL 86

    Accepted Solution

    No - not without native code
    LVL 25

    Expert Comment

    As CEHJ has said, not without Native code.. if you can do some C/C++, then you can see here for how to create a Keyboard Hook:
    You'd then need to use JNI to implement this into your Java app; but I'll let CEHJ explain how to do that ;) hehehe (don't ask me!).
    LVL 86

    Expert Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    This video teaches viewers about errors in exception handling.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now