Hi, what I am trying to do is simple:

I just want to execute something depend on what the user presses. Here's the pseudocode:

if(user presses 1) {
do this
} else {
do that
}

ps.
I was reading about

java.awt.AWTKeyStroke;

and is that what I need to use? If so how?

int c = System.in.read();
System.out.println("You pressed the key " + (char)c + " whose ascii value is " + c);

Look at these 2 sites:

KeyListener API

Tutorial for KeyListener

In general, KeyListener works exactly the same as ActionListener, except instead of overriding actionPerformed() you need to override keyPressed(), keyReleased(), and keyTyped().

Play around with this interface and see what results you get.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.