jme.controller
Interface KeyboardController

All Known Implementing Classes:
AbstractGameController

public interface KeyboardController

KeyboardController provides an interface for interacting with the keyboard. The keyboard can be queried in two ways, individual polls, or buffered mode. If poll mode is used, all keys that are pressed when poll is called is set to true. If buffered mode is used, all pressed keys are entered into the buffer and each key press can be retrieved via a call to next.

Version:
1
Author:
Mark Powell

Method Summary
 boolean isKeyDown(java.lang.Object keyCode)
          isKeyDown returns a boolean value if a key is pressed or not.
 int next()
          next returns the key code of the next key in the buffer.
 void pollKeyboard()
          pollKeyboard updates the state of the key variables to be either true or false depending on the current keyboard.
 void setBuffered()
          setBuffered sets the keyboard to buffered mode.
 

Method Detail

pollKeyboard

public void pollKeyboard()
pollKeyboard updates the state of the key variables to be either true or false depending on the current keyboard.


isKeyDown

public boolean isKeyDown(java.lang.Object keyCode)
isKeyDown returns a boolean value if a key is pressed or not. True is returned if the key is pressed, false otherwise.

Parameters:
keyCode - which key to check for. Implementations job to define how a keyCode is defined.
Returns:
true if the key is pressed, false if it is not.

setBuffered

public void setBuffered()
setBuffered sets the keyboard to buffered mode. All keyboard input will be placed in the buffer and can be retrieved one key press at a time using next.


next

public int next()
next returns the key code of the next key in the buffer. To correctly use this, a call to setBuffered needs to be made.