Just thought this may help some people get started with the cool JInput action:
import net.java.games.input.*;
public class KeyboardTest {
Keyboard kb = null;
public KeyboardTest() {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cont = ce.getControllers();
System.out.println("cont: " + cont.length);
for (int i = 0; i < cont.length; i++) {
if (cont[i].getType() == cont[i].getType().KEYBOARD) {
kb = (Keyboard) cont[i];
}
}
for(int i = 0; i < 100000; i++) {
keyboardupdate();
}
System.out.println("done...");
}
public void keyboardupdate() {
kb.poll();
Axis[] ax = kb.getAxes();
for (int x = 0; x < ax.length; x++) {
float num = ax[x].getPollData();
if (num != ax[x].getDeadZone()) {
if (ax[x].getName().equalsIgnoreCase("key 110")) {
System.out.println("up arrow");
}
}
}
}
}