I was just wondering how I’d go about implementing a system that notifies a listener class whenever a given key is pressed? Is there some handy LWJGL utility for it, or do I need to poll across all keys and handle it that way?
You have to poll in the sense that you check the keyboard every frame, but not in the sense of checking every key to see if it’s changed. Like so:
while( Keyboard.next() )
{
int key = Keyboard.getEventKey();
boolean down = Keyboard.getEventKeyState();
boolean repeat = Keyboard.isRepeatEvent();
char c = Keyboard.getEventCharacter();
// do whatever
}
That’ll take you through all the changes to keyboard state since the last time you checked.
Much obliged!