• 0

JAVA: Getting the press any key to continue thing


Question

Hey guys as the thread name implies, how do u do it, im doing console programming in java, and i wann know how to do the press any key to continue thing, so watever key is pressed then it does something, i know how to read user input but i dont think thats how to do it. Thanks

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

ummm so wait

public void Test()

{

[this is a block of code that's executed]

System.out.println("Press enter to return to menu");

System.in.read();

}

ummm but cant i put it in a if statement becoz i need to know when enter has been pressed so that i can call another method

Link to comment
Share on other sites

  • 0

keyListener is really more for GUI. I'm not sure there's a prewritten class in the Java API for a command line keyListener but they're very easy to use in AWT/Swing.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.