Thanks to MichaelHouse for his suggestion, but what I actually found works (since those methods he suggested didn't appear to exist for the Keyboard class I had), is to set a boolean waitingToSet and in my update method, I had this:
if (waitingToSet){
if (Keyboard.getEventKeyState()){
System.out.println(Keyboard.getKeyName(Keyboard.getEventKey()));
waitingToSet = false;
}
}
This worked perfectly for me. Of course you can just then go and bind that Keyboard.getEventKey() returned value as the setting you want.
EDIT: Just a caveat: if you're planning on using this with LibGDX, it won't work properly. The Integer values for the Keyboard class and the Input.Keys field are different, so calling Gdx.Input.isKeyPressed(i) where i is the int value you caught earlier, will map to the wrong key.
It turned out to be a huge mission for me to get new key mappings to work properly for LibGDX. Ended up using a Preferencesfile and writing my own method that looped through every possible Key and/or button to return the proper one:
public static int getKey(){
for (int i=0;i<256;i++){
if (Gdx.input.isKeyJustPressed(i)){
return i;
}
}
return -1;
}
This worked perfectly. So change the Keyboard.getEventKeyState()to Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) and then call the above method inside the if statement. Then you'll have the right key.