I think you are confusing some concepts..... If you use your keyboard to move your player, then you usually store the location of the player's position in the player's object.
If you use your mouse to move the player, then you use the location of the mouse on the screen to set the player's position on the game.
So, there is no such thing as location of keyboard as there is for location of mouse pointer.
In any case, whichever way you update the location of your player, his position is still stored in the object. I.e.
class Sprite {
Point position;
Texture texture;
}
class Level implements MouseListener, KeyListener {
Sprite player;
...
void update(...) {
// THIS IS THE POSITION OF YOUR PLAYER
//whether you updated it with mouse or keybaord
Point position = player.getPosition();
// Do something with this...
}
// Update player position using mouse
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
player.setPosition(new Point(newx, newy);
}
// Update player position using keyboard
public void keyPressed(int key, char c) {
if (key == Input.KEY_W) {
player.getPosition().X += 1;
} else if (key == Input.KEY_S) {
player.getPosition().X -= 1;
} else if (key == Input.KEY_A) {
player.getPoisition().Y -= 1;
} else if (key == Input.KEY_D) {
player.getPosition().Y += 1;
}
}
}
Hope this helped clear some things...