Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:34:02+00:00 2026-06-01T19:34:02+00:00

I have a bot program to test my server. I would like it to

  • 0

I have a bot program to test my server. I would like it to exit the loop if any key was press, but do not want it to stop and wait until a key was press. thus the loop would keep running until any key on the keyboard was press.

This is how I’m trying to do it now, but does not work

        if (System.in.available()>0)
        {
            System.out.println("key pressed");
            break; // exit loop
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:34:03+00:00Added an answer on June 1, 2026 at 7:34 pm

    Your options are:

    • Create a GUI window. You can can receive asynchronous key events from an awt/swing window via key event listener.

      See code sample in last answer here.

    • Create separate thread in your program to wait for enter key press and then signal the main loop thread to end.

    • Use a native library like jInput or jLine (or write your own simpler equivalent using jni/jna).

      This allows you hook in to native OS’s asynchronous key handling, although even then, there are often subtle dependencies on a windowing system being in place first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For our company I'd like to have a Python based IRC bot which checks
I am trying to make my own Jabber bot but i have run into
I want to render for facebook bot special data. I have og.html.erb <!DOCTYPE html><html><head>
I'd like to try and create a program playing a game. I.e. a bot.
I have a little problem with google bot, I have a server working on
I have a simple java program that runs fine in eclipse but cannot find
I have a genetic expression tree program to control a bot. I have a
I have, a game bot which runs through console. I don't think i'm going
i been trying to code an IRC bot, while i have succeed. I am
I am trying to find a MediaWiki bot or extension that would do the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.