(slick 2d) and lwjgl input

I really like lwjgl’s input system.


if (Keyboard.isKeyDown(SCROLL_LEFT)) {view.scrollX(-5);}

This can be used for moving sprites about, etc.

Then there is:



while (Keyboard.next()) {
			System.out.println("B Key Pressed");
			if (Keyboard.getEventKeyState()) {
		        if (Keyboard.getEventKey() == Keyboard.KEY_B) {
		        	System.out.println("B Key Pressed");
		        }
		        if (Keyboard.getEventKey() == Keyboard.KEY_S) {
		        	System.out.println("S Key Pressed");
		        }
		        if (Keyboard.getEventKey() == Keyboard.KEY_D) {
		        	System.out.println("D Key Pressed");
		        }
		    	} else {
		    		if (Keyboard.getEventKey() == Keyboard.KEY_A) {
		    			System.out.println("A Key Released");
		    		}
		    		if (Keyboard.getEventKey() == Keyboard.KEY_S) {
		    			System.out.println("S Key Released");
		    		}
		    		if (Keyboard.getEventKey() == Keyboard.KEY_D) {
		    			System.out.println("D Key Released");
		    		}
		    	}
			}


for individual presses and releases of buttons. You can put these pieces of code in your own Input class and add a method poll(); That way you won’t miss any events and you won’t have synchronizing trouble since you’ll only call poll() in your update method. There’s also the benefit that you only go through the while-loop above as many times as you have keys pressed. If the if/else statement is replaced with a switch you have a speedy way of checking the input.

However, in slick 2d, they’ve remade it. In the Input class you have no way of polling the events that has been fired. This has already been done somewhere, sometime. Here you have a choice of having event-fired methods with


public void keyPressed(int key, char c) {action}

This will mess up synchronization though, since this method will be called at any time.

Then there is the


.isKeyPressed(keycode)

if (input.isKeyPressed(Input.space)
     do something



which can be called in the update method. However, if you use a lot of buttons, that means a lot of if-statements and that is bad design and time consuming.

Is there no way to do the lwjgl thing in slick?