Hello,
In JPCT apps, you have the KeyMapper class to help you. Here is an example of how you can use it (taken from i don't remember which example of Egon)
private void poll(){
KeyState state = null;
do{
state = keyMapper.poll(); // call to the poll method of the KeyMapper instance
if (state!=KeyState.NONE){
keyAffected(state); // call to a keyAffected method that will describe the action to do once a key is pushed
}
}
while (state != KeyState.NONE);
}
And an example of the keyAffected related method
private void keyAffected(KeyState state){
int code = state.getKeyCode();
boolean event = state.getState();
System.out.println(code);
switch(code){
case (KeyEvent.VK_ESCAPE):
escape = event;
break;
case (KeyEvent.VK_LEFT):
left = event;
break;
case (KeyEvent.VK_RIGHT):
right = event;
break;
case (KeyEvent.VK_UP):
forward = event;
break;
case (KeyEvent.VK_DOWN):
backward=event;
break;
}
Manu