org.deken.game.input
Class KeyPollMonitor

java.lang.Object
  extended by org.deken.game.input.KeyPollMonitor
All Implemented Interfaces:
keyPolling, Updateable

public class KeyPollMonitor
extends java.lang.Object
implements Updateable, keyPolling

Title: KeyPollMonitor

Description:

Copyright: Copyright (c) Dec 3, 2013

Version:
1.0
Author:
Gary Deken

Constructor Summary
KeyPollMonitor()
           
 
Method Summary
 java.lang.String getKeyCache()
          Returns the keys typed
 java.lang.String getName()
           
 boolean isAnyKeyDown()
          In case you want to know if a user is pressing a key but don't care which one.
 boolean isAnyKeyUp()
          In case you want to know if a user released a key but don't care which one.
 boolean isKeyDown(int key)
          Returns true if the key (0-256) is being pressed use the KeyEvent.VK_ key variables to check specific keys.
 boolean isKeyUp(int key)
          Returns true if the key (0-256) is being pressed use the KeyEvent.VK_ key variables to check specific keys.
 void processKeyPressed(java.awt.event.KeyEvent event)
          Set the state elements for whatever key was pressed.
 void processKeyReleased(java.awt.event.KeyEvent e)
          Set the state elements for whatever key was released.
 java.lang.String readKeyCache()
           
 void update(long elapseTime)
          Only resets the key state up because you don't want keys to be showing as up forever which is what will happen unless the array is cleared.
 void updateKeyCache(char c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyPollMonitor

public KeyPollMonitor()
Method Detail

getKeyCache

public java.lang.String getKeyCache()
Returns the keys typed

Specified by:
getKeyCache in interface keyPolling
Returns:
String

isKeyDown

public boolean isKeyDown(int key)
Returns true if the key (0-256) is being pressed use the KeyEvent.VK_ key variables to check specific keys.

Specified by:
isKeyDown in interface keyPolling
Parameters:
key - The ascii value of the keyboard key being checked
Returns:
true is that key is currently being pressed.

isKeyUp

public boolean isKeyUp(int key)
Returns true if the key (0-256) is being pressed use the KeyEvent.VK_ key variables to check specific keys.

Specified by:
isKeyUp in interface keyPolling
Parameters:
key - The ascii value of the keyboard key being checked
Returns:
true is that key is currently being pressed.

isAnyKeyDown

public boolean isAnyKeyDown()
In case you want to know if a user is pressing a key but don't care which one.

Specified by:
isAnyKeyDown in interface keyPolling
Returns:
true if one or more keys are currently being pressed.

isAnyKeyUp

public boolean isAnyKeyUp()
In case you want to know if a user released a key but don't care which one.

Specified by:
isAnyKeyUp in interface keyPolling
Returns:
true if one or more keys have been released this frame.

processKeyPressed

public void processKeyPressed(java.awt.event.KeyEvent event)
Set the state elements for whatever key was pressed.

Parameters:
event -

processKeyReleased

public void processKeyReleased(java.awt.event.KeyEvent e)
Set the state elements for whatever key was released.

Parameters:
e -

readKeyCache

public java.lang.String readKeyCache()
Specified by:
readKeyCache in interface keyPolling

update

public void update(long elapseTime)
Only resets the key state up because you don't want keys to be showing as up forever which is what will happen unless the array is cleared.

Specified by:
update in interface Updateable
Parameters:
elapseTime - long

updateKeyCache

public void updateKeyCache(char c)

getName

public java.lang.String getName()
Specified by:
getName in interface Updateable
Returns: