LWJGL keyboard function to only execute once?

Hi,

I am making a menu system, and I was wondering how I should get it to only execute a command once as opposed to keep executing it as long as the key is down, so that it only selects the next menu item as opposed to going all the way to the last one.

here is the code I am using for it now:

   public void handleInput() {   
		if(Keyboard.isKeyDown(Keyboard.KEY_RETURN)) select();
		if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
			if(currentChoice > 0) {
			//	JukeBox.play("menuoption", 0);
				currentChoice--;
			}
		}
		if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
			if(currentChoice < options.length - 1) {
				currentChoice++;
			}			
		}
     }

I tried using an event but that didnt really work either,

Thanks,

  • Dan

Use events and disable repeats.