Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.threed.jpct.util
Class KeyMapper

    java.lang.Object
      com.threed.jpct.util.KeyMapper

All Implemented Interfaces:
  java.util.EventListener, java.awt.event.KeyListener

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

KeyMapper is convenience class to ease the different handling of the keyboard when using hard- or software rendering. It provides a uniform way to access the keyboard.

Constructor Summary
`KeyMapper()` Use this constructor to create a KeyMapper that works in combination with hardware rendering (i.e. that is using LWJGL's methods to access the keyboard).
`KeyMapper(java.awt.Component comp)` Use this construtor to create a KeyMapper that works on an AWT/Swing component, which is usually your frame (or whatever) where the rendered output will be displayed onto.

Method Summary
`void` | `destroy()` Destroys the KeyMapper.
`void` | `keyPressed(java.awt.event.KeyEvent e)` Has to be public, because KeyMapper implements KeyListener.
`void` | `keyReleased(java.awt.event.KeyEvent e)` Has to be public, because KeyMapper implements KeyListener.
`void` | `keyTyped(java.awt.event.KeyEvent e)` Has to be public, because KeyMapper implements KeyListener.
`KeyState` | `poll()` Poll the keyboard until no further KeyStates are available.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### KeyMapper

    public KeyMapper()

  Use this constructor to create a KeyMapper that works in combination with hardware rendering (i.e. that is using LWJGL's methods to access the keyboard).

### KeyMapper

    public KeyMapper(java.awt.Component comp)

  Use this construtor to create a KeyMapper that works on an AWT/Swing component, which is usually your frame (or whatever) where the rendered output will be displayed onto. The KeyMapper will automatically register itself as a KeyListener of the component. To deregister, call destroy on this KeyMapper.

Parameters:
  `comp` - the component

Method Detail

### destroy

    public void destroy()

  Destroys the KeyMapper. This will free up used resources and will deregister the KeyMapper if required. It's mandatory to call this method before exiting your application or instantiating another KeyMapper.

### poll

    public KeyState poll()

  Poll the keyboard until no further KeyStates are available. In that case, KeyState.NONE will be returned.

  Returns:
    the KeyState (i.e. which key has been pressed/released)

### keyTyped

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

  Has to be public, because KeyMapper implements KeyListener. No need to call this method directly.

  Specified by:
    `keyTyped` in interface `java.awt.event.KeyListener`
  Parameters:
    `e` - the KeyEvent

### keyPressed

    public void keyPressed(java.awt.event.KeyEvent e)

  Has to be public, because KeyMapper implements KeyListener. No need to call this method directly.

  Specified by:
    `keyPressed` in interface `java.awt.event.KeyListener`
  Parameters:
    `e` - the KeyEvent

### keyReleased

    public void keyReleased(java.awt.event.KeyEvent e)

  Has to be public, because KeyMapper implements KeyListener. No need to call this method directly.

  Specified by:
    `keyReleased` in interface `java.awt.event.KeyListener`
  Parameters:
    `e` - the KeyEvent

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD