Q:

Java 2D Game KeyListener Not Fulfilling It's Destiny

I've decided it's time to take my programming to the next step: Making A Game. So far I've been able to code everything alright, maybe having to Google some stuff I'm not too familiar with, but I feel like it should work. The graphics are being painted and all that's nice and dandy, but when it comes to the Key Listeners, that's where things went wrong. I made an inner class that implemented Key Listener, then added it in the Board constructor. I guess you'll just have to look at the code but it's pretty long and a bit messy. This is my first time doing this, so some stuff is probably unnecessary and I may just be forgetting something really obvious.
Main Class: 
import javax.swing.*;

public class Game extends JFrame{
public static void main(String[] args){
    new Game();
}
public Game(){

    add(new Board());

    setTitle("Hi mom");
    setSize(555,330);
    setResizable(false);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(3);
    setVisible(true);
}
}

Board Class:
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class Board extends JPanel implements ActionListener {

Image background;
Player p;
int k;
boolean moving;

public Board() {

    setFocusable(true);

    Timer timer = new Timer(25, this);
    timer.start();

    ImageIcon img = new ImageIcon(getClass().getResource("images/map.png"));
    background = img.getImage();

    addKeyListener(new Kl());

    p = new Player();

}

public void paint(Graphics g) {
    g.drawImage(background, 0, 0, null);
    g.drawImage(p.getPlayer(), p.setX(30), p.setY(187), null);
}

public void actionPerformed(ActionEvent e) {

    if (k == 'W' && moving == true) {
        p.move(0,-5);
    }
    if (k == 'S' && moving == true) {
        p.move(0,5);
    }
    if (k == 'D' && moving == true) {
        p.move(5,0);
    }
    if (k == 'A' && moving == true) {
        p.move(-5,0);
    }

    repaint();
}

public class Kl implements KeyListener {
    public void keyPressed(KeyEvent e) {
        k = e.getKeyCode();
        moving = true;
    }

    public void keyReleased(KeyEvent e) {
        moving = false;
    }

    public void keyTyped(KeyEvent e) {
    }

}
}

Player Class:
import javax.swing.*;
import java.awt.*;
public class Player{
int x, y;
Image player;
public Player(){
    ImageIcon img = new ImageIcon(getClass().getResource("images/player.png"));
    player = img.getImage();
}
public Image getPlayer(){
    return player;
}
public void move(int x, int y){
    this.x += x;
}
public int setX(int x){
    this.x = x;
    return x;
}
public int setY(int y){
    this.y = y;
    return y;
}
}

A:

The problem is KeyListener will only trigger key events when the component it is registered to is focusable AND has keyboard focus.  Simply calling setFocsuable isn't enough.  This just means that the component is "capable" of receiving keyboard focus, not that it has it.
Instead, you should be using the Key Bindings API, which has the means to over come this limitation, amongst other things.

