rlgamekit.control
Class KeyInputHandler

java.lang.Object
  extended by rlgamekit.control.KeyInputHandler
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class KeyInputHandler
extends java.lang.Object
implements java.awt.event.KeyListener

The KeyInputHandler calls game actions which are triggered by key events.

See Also:
GameAction

Constructor Summary
KeyInputHandler()
          Craetes a new KeyInputHandler with an empty list of actions.
 
Method Summary
 void addAction(ActionKey key, GameAction action)
          Add a new game action for the given key binding.
 GameAction getAction(ActionKey key)
          Get the action bound to the key event.
 java.util.Set<ActionKey> getKeys()
          Get a set of all defined action keys.
 void keyPressed(java.awt.event.KeyEvent e)
          Implements KeyListener, calls onKeyPressed() for matching actions
 void keyReleased(java.awt.event.KeyEvent e)
          Implements KeyListener, calls onKeyRelease() for matching actions
 void keyTyped(java.awt.event.KeyEvent e)
          Implements KeyListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyInputHandler

public KeyInputHandler()
Craetes a new KeyInputHandler with an empty list of actions.

Method Detail

addAction

public void addAction(ActionKey key,
                      GameAction action)
Add a new game action for the given key binding.

Parameters:
action - The game action to add.
key - The key to bind the action to.

getAction

public GameAction getAction(ActionKey key)
Get the action bound to the key event.

Parameters:
key - The action key
Returns:
The bound action or null if no actions was bound to this event.

getKeys

public java.util.Set<ActionKey> getKeys()
Get a set of all defined action keys.

Returns:
a set of all defined action keys.

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Implements KeyListener

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Implements KeyListener, calls onKeyPressed() for matching actions

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Implements KeyListener, calls onKeyRelease() for matching actions

Specified by:
keyReleased in interface java.awt.event.KeyListener