GF4J 0.9.4 Beta

gameframe.input
Interface KeyboardDevice

All Known Implementing Classes:
CEventQueue, CKeyboard

public interface KeyboardDevice

This interface is meant for input devices that are keyboard-like in their operation. This means that the device has several (more than 10) buttons that are on/off type. The keycodes used in this interface are those defined in java.awt.event.KeyEvent class. If the devices buttons can't be directly mapped to those keycodes the mapping should be made in a such way that order of the keys are preserved, when counting the keys from topleft to the right, row by row. Also if the input device has directional control buttons, those must be mapped to cursor keycodes (VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT).

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

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 down or 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).
 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).
 

Method Detail

isKeyDown

public boolean isKeyDown(int keyCode)
Returns true if the key is down or 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). The keycode is one of the VK_xxx codes from java.awt.event.KeyEvent class.
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
True if the key is down.
Since:
GameFrame for Java 0.9

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). The keycode is one of the VK_xxx codes from java.awt.event.KeyEvent class.
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
True if the key was down.
Since:
GameFrame for Java 0.9

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). The keycode is one of the VK_xxx codes from java.awt.event.KeyEvent class.
Parameters:
keyCode - The keycode of the key we want to query.
Returns:
The number of times the key was stroken (pressed and released)
Since:
GameFrame for Java 0.9

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.
Returns:
Any typed alphanumeric keys
Since:
GameFrame for Java 0.9

finalize

public void finalize()
Releases all resources held by the keyboard device implementation. This method may be called several times.
Overrides:
finalize in class java.lang.Object
Since:
GameFrame for Java 0.9

GF4J 0.9.4 Beta