Q:

Java: making basic controls

I am going to get into GUI soon and I wanted to know a way to enable a java program to detect if a user presses a key on the keyboard by using ActionListener, then determining what to do depending on what key the user pressed. I have heard of variables called char variables that can hold a letter and I was also wondering if these have some involvement in testing user input.
If using ActionListener to detect user input is unnecessary, please explain to me in the simplest way how programmers usually make games that have the classic W A S D controls and stuff like that.

A:

KeyListener is the interface you're looking for. Create a class implementing KeyListener, then call addKeyListener(...) on your window (a class extending JFrame). Specifically, the method keyPressed(KeyEvent e) can be used to respond to keyboard button pushes.
To elaborate, ActionListeners are specifically for handling the firing of various "Actions". As it pertains to you, that means the clicking of JButtons or JMenuItems. ActionListeners won't catch keyboard presses or other mouse movement such as dragging.
Here's a bit of a class I wrote for a game I'm working on to handle keyboard input. It uses the arrow keys for movement, the Z key as the Abutton and the X key as the B button (think traditional emulator setup).
/** Manager for all keyboard input. Only singleton instance is allowed. */
public class KeyboardListener implements KeyListener{

    /** The up key code */
    public static final int UP = KeyEvent.VK_UP;
    /** The left key code */
    public static final int LEFT = KeyEvent.VK_LEFT;
    /** The down key code */
    public static final int DOWN = KeyEvent.VK_DOWN;
    /** The right key code */
    public static final int RIGHT = KeyEvent.VK_RIGHT;
    /** The "a" (main button / weak confirm button) key code */
    public static final int A = KeyEvent.VK_Z;
    /** The "b" (secondary button / weak decline button) key code */
    public static final int B = KeyEvent.VK_X;
    /** The "start" (tertiary / strong confirm button) key code */
    public static final int START = KeyEvent.VK_ENTER;
    /** The "esc" (tertiary / strong decline button) key code */
    public static final int ESC = KeyEvent.VK_ESCAPE;

    /** The singleton instance of keyboardListener to be used by all frames */
    protected static final KeyboardListener instance = new KeyboardListener();

    /** Constructor for KeyboardListener */
    private KeyboardListener(){}

    /** The frame this KeyboardListener is listening to */
    private Frame frame; //Note - Frame is a class I've written, Frame extends JFrame

    /** Set the Frame the KeyboardListener is listening to */
    public static void setFrame(Frame f){
        instance.frame = f;
        instance.frame.addKeyListener(instance);
    }

    /** Unused */
    @Override
    public void keyTyped(KeyEvent e) {}

    /** Handle key presses */
    @Override
    public void keyPressed(KeyEvent e) { 
        int keyCode = e.getKeyCode();
        if(keyCode == UP){
          //Handle push of the up arrow
        }
        //etc....
    }

    /** Unused */
    @Override
    public void keyReleased(KeyEvent e) {};
}

