while(Keyboard.next()) not responding

Started by CrossKun, May 15, 2013, 20:39:45

Previous topic - Next topic

CrossKun

Good evening fellows!

Story:
At first I was learning LWJGL by codinguniverse and now switched to the online book "Learning Modern OpenGL" with rosicks/mckessons port of the tutorial source code.

Problem:
Back then when I was practicing the codingUniverse tutorials the following code would work
while(Keyboard.next()){
			if(Keyboard.getEventKey() == Keyboard.KEY_F){
				System.out.println("!");
				
			}

but when I try to play around a bit besides the LearningModern..tutorials, this code will be ignored.
simple "if(Keyboard.isKeyDown(Key_F) System.out.Println("!")" works fine, which confuses me  ???

Could someone give me a hint what Im missing?

I tried to search for this problem already but couldnt find a solution that fits :/

Sincerly,
Cross!

quew8

Make sure you are calling Display.update() or Keyboard.poll() (update calls this) at the end of your loop. This polls the keyboard for events as you might guess.

CrossKun

Ah, great thanks more than 2 tons for the advice! :)

I found the solution due to this.
The class of the display tutorial "lwjglwindow.java" had already a while(keyboard.next()) loop, as soon as I removed that one and tried it in my own class it worked!

I really appreciate it, that solutions and ideas are posted here so quickly, thanks a lot!