How to handle user input in Java correctly?
<p>I'm implementing a class X that extends javax.swing.JFrame
I added the inner class KeyInputHandler inside X with the following code:</p>

<pre><code>private class KeyInputHandler extends KeyAdapter {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT) {


}
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
    ...
}
if (e.getKeyCode() == KeyEvent.VK_UP) {
    ...
}
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
    ...
}
if (e.getKeyCode() == KeyEvent.VK_B) {
    ...
}
}
}
</code></pre>

<p>But for some reason it doesn't recognize my input. Do I have to add something else to the class X?</p>
