<p>I'm trying to implement a <code>KeyListener</code> for my <code>JFrame</code>. On the constructor, I'm using this code:</p>

<pre><code>System.out.println("test");
addKeyListener(new KeyListener() {
    public void keyPressed(KeyEvent e) { System.out.println( "tester"); }

    public void keyReleased(KeyEvent e) { System.out.println("2test2"); }

    public void keyTyped(KeyEvent e) { System.out.println("3test3"); }
});
</code></pre>

<p>When I run it, the <code>test</code> message comes up in my console. However, when I press a key, I don't get any of the other messages, as if the <code>KeyListener</code> was not even there.</p>

<p>I was thinking that it could be because the focus is not on the <code>JFrame</code><br>
and so they <code>KeyListener</code> doesn't receive any events.  But, I'm pretty sure it is.</p>

<p>Is there something that I am missing?</p>

Hmm.. what class is your constructor for? Probably some class extending JFrame? The window focus should be at the window, of course but I don't think that's the problem.
I expanded your code, tried to run it and it worked - the key presses resulted as print output. (run with Ubuntu through Eclipse):
```
```
public class MyFrame extends JFrame {
    public MyFrame() {
        System.out.println("test");
        addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                System.out.println("tester");
            }

            public void keyReleased(KeyEvent e) {
                System.out.println("2test2");
            }

            public void keyTyped(KeyEvent e) {
                System.out.println("3test3");
            }
        });
    }

    public static void main(String[] args) {
        MyFrame f = new MyFrame();
        f.pack();
        f.setVisible(true);
    }
}
```
```