com.golden.gamedev.funbox
Class KeyCapture

java.lang.Object
  |
  +--com.golden.gamedev.funbox.KeyCapture

public class KeyCapture
extends Object

Capturing key sequence combination, usually used to turn on cheat mode.

For example:

    KeyCaptureListener listener = new KeyCaptureListener() {
       public void keyCaptured(KeyCapture src) {
          System.out.println("hello world");
       }
    };
    String key = "HYPERSPEED";
    KeyCapture keycap = new KeyCapture(GameCore.bsInput, key, 1000, listener);

    // in game update() method
    // pressing "hyperspeed" will print out "hello world" to the console
    keycap.update();
 


Field Summary
 boolean DEBUG
           
protected  BaseInput input
           
 
Constructor Summary
KeyCapture(BaseInput input, int[] key, int delay, KeyCaptureListener l)
          Constructs new KeyCapture
KeyCapture(BaseInput input, String keyString, int delay, KeyCaptureListener l)
           
 
Method Summary
 int getDelayTime()
           
 KeyCaptureListener getKeyCaptureListener()
           
 int[] getKeySequence()
           
 String getKeyString()
           
 int[] getModifiers()
           
 boolean isActive()
           
 void setActive(boolean b)
           
 void setDelayTime(int i)
           
 void setKeyCaptureListener(KeyCaptureListener l)
           
 void setKeySequence(int[] key)
           
 void setKeySequence(String st)
          Parse String st into key sequence.
 void setModifiers(int i)
           
 void setModifiers(int[] i)
           
 String toString()
           
 void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

input

protected final BaseInput input

DEBUG

public boolean DEBUG
Constructor Detail

KeyCapture

public KeyCapture(BaseInput input,
                  int[] key,
                  int delay,
                  KeyCaptureListener l)
Constructs new KeyCapture

Parameters:
input -
key -
delay -
l -

KeyCapture

public KeyCapture(BaseInput input,
                  String keyString,
                  int delay,
                  KeyCaptureListener l)
Method Detail

getModifiers

public int[] getModifiers()

setModifiers

public void setModifiers(int[] i)

setModifiers

public void setModifiers(int i)

getKeySequence

public int[] getKeySequence()

setKeySequence

public void setKeySequence(int[] key)

setKeySequence

public void setKeySequence(String st)
Parse String st into key sequence.

Example:

     String key = "HYPERSPEED";
     keyCapture.setKeySequence(key);
 

Parameters:
st - String to be parsed into key sequence
Throws:
RuntimeException - If the String st can not be parsed.
See Also:
setKeySequence(int[])

getDelayTime

public int getDelayTime()

setDelayTime

public void setDelayTime(int i)

isActive

public boolean isActive()

setActive

public void setActive(boolean b)

getKeyString

public String getKeyString()

getKeyCaptureListener

public KeyCaptureListener getKeyCaptureListener()

setKeyCaptureListener

public void setKeyCaptureListener(KeyCaptureListener l)

update

public void update()

toString

public String toString()
Overrides:
toString in class Object