GF4J 0.9.4 Beta

gameframe.engines.jdk11x
Class CKeyboard

java.lang.Object
  |
  +--gameframe.engines.jdk11x.CKeyboard
All Implemented Interfaces:
java.util.EventListener, KeyboardDevice, java.awt.event.KeyListener

class CKeyboard
extends java.lang.Object
implements KeyboardDevice, java.awt.event.KeyListener

Implementation of the keyboard device for Java 1.1 platform.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.4

Field Summary
private static int KEY_DOWN
          Enumerated value for state key is down.
private static int KEY_UP
          Enumerated value for state key is up.
private static int KEY_WAS_DOWN_NOT_READ
          Enumerated value for state where key was down but was not read during that time.
private static int KEY_WAS_DOWN_READ
          Enumerated value for state where key was down and was read during that time.
private  int[] m_aKeyStates
          States of the keys.
private  int[] m_aNumKeystrokes
          Number of times the key was stroken.
private  java.awt.Component m_focusComponent
          Reference to the focus component that is the source of keyboard events.
private  int m_lastAlphanumericKey
          The last alphanumeric key value typed.
 
Constructor Summary
(package private) CKeyboard(java.awt.Component component)
          Constructs a keyboard engine that has the given component set as the focus component.
 
Method Summary
 void finalize()
          Releases all resources held by the keyboard device implementation.
 int getKeyDownCount(int keyCode)
          Returns the number of times the key has been stroken since last reading (after last call made to isKeyDown or getKeyDownCount methods with the same key code).
 int getTypedAlphanumericKey()
          Returns any typed alphanumeric keys (including space and dot) as int values that correspond to that keys char value or -1 if no such keys were pressed after last invokation of this method.
 boolean isKeyDown(int keyCode)
          Returns true if the key is currently down
 void keyPressed(java.awt.event.KeyEvent event)
           
 void keyReleased(java.awt.event.KeyEvent event)
           
 void keyTyped(java.awt.event.KeyEvent event)
           
 boolean wasKeyDown(int keyCode)
          Returns true if the key was briefly kept down after last reading of the keys state (after last call made to isKeyDown or getKeyDownCount methods with the same key code).
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_focusComponent

private java.awt.Component m_focusComponent
Reference to the focus component that is the source of keyboard events.

m_aKeyStates

private int[] m_aKeyStates
States of the keys. Can have one of the enumerated KEYSTATE_ values.

m_aNumKeystrokes

private int[] m_aNumKeystrokes
Number of times the key was stroken.

KEY_UP

private static final int KEY_UP
Enumerated value for state key is up.

KEY_DOWN

private static final int KEY_DOWN
Enumerated value for state key is down.

KEY_WAS_DOWN_NOT_READ

private static final int KEY_WAS_DOWN_NOT_READ
Enumerated value for state where key was down but was not read during that time.

KEY_WAS_DOWN_READ

private static final int KEY_WAS_DOWN_READ
Enumerated value for state where key was down and was read during that time.

m_lastAlphanumericKey

private int m_lastAlphanumericKey
The last alphanumeric key value typed.
Constructor Detail

CKeyboard

CKeyboard(java.awt.Component component)
Constructs a keyboard engine that has the given component set as the focus component.
Parameters:
component - The component that where listeners are registered.
Method Detail

isKeyDown

public boolean isKeyDown(int keyCode)
Returns true if the key is currently down
Specified by:
isKeyDown in interface KeyboardDevice
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
True if the key is or was down.

wasKeyDown

public boolean wasKeyDown(int keyCode)
Returns true if the key was briefly kept down after last reading of the keys state (after last call made to isKeyDown or getKeyDownCount methods with the same key code).
Specified by:
wasKeyDown in interface KeyboardDevice
Following copied from interface: gameframe.input.KeyboardDevice
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
True if the key was down.

getKeyDownCount

public int getKeyDownCount(int keyCode)
Returns the number of times the key has been stroken since last reading (after last call made to isKeyDown or getKeyDownCount methods with the same key code).
Specified by:
getKeyDownCount in interface KeyboardDevice
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
The number of times the key was stroken (pressed and released)

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
Specified by:
keyTyped in interface java.awt.event.KeyListener

getTypedAlphanumericKey

public int getTypedAlphanumericKey()
Returns any typed alphanumeric keys (including space and dot) as int values that correspond to that keys char value or -1 if no such keys were pressed after last invokation of this method.
Specified by:
getTypedAlphanumericKey in interface KeyboardDevice
Returns:
Any typed alphanumeric keys

finalize

public void finalize()
Releases all resources held by the keyboard device implementation.
Specified by:
finalize in interface KeyboardDevice
Overrides:
finalize in class java.lang.Object

GF4J 0.9.4 Beta