All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cs005.event.KeyInteractor

java.lang.Object
   |
   +----cs005.event.KeyInteractor

public abstract class KeyInteractor
extends Object
Package: cs005.event
Class: KeyInteractor
Direct complaints to: sco
Last Modified June 7, 1997 7:10 pm

This is the abstract class for all KeyInteractions. If you want to create an object that can handle a key press, you must subclass off of this class and fill in the keyPress and keyRelease methods (one of them can be empty). You should never call those methods yourself! They are called automatically when the key is pressed. When a KeyInteractor is created it is OFF. You need to turn it on before you can expect it to work.

The key you pass in is either the ascii value of the key you want to detect presses from, or the actual character you want to use. Remember, case matters. Also, for keys that do not have ascii values, consult the java.awt.event documentation. For example, passing in either 'd' or 100 would result in a KeyInteractor that called its methods when the d key was pressed (with no modifiers).


Constructor Index

 o KeyInteractor(App, char)
Constructor: KeyInteractor

This will create a new interactor with the given character key.

 o KeyInteractor(App, int)
Constructor: KeyInteractor

This will create a new interactor with the given key.

 o KeyInteractor(KeyPressManager, int)
Constructor: KeyInteractor

This is the constructor to use if an App isn't being used.

Method Index

 o keyPress()
Method: keyPress

This method is called whenever the Interactor's key is pressed.

 o keyRelease()
Method: keyReleased

This method is called whenever the Interactor's key is released.

 o turnOff()
Method: turnOff

This turns off the KeyInteractor.

 o turnOn()
Method: turnOn

This turns on the KeyInteractor.

Constructors

 o KeyInteractor
 public KeyInteractor(App app,
                      int key)
Constructor: KeyInteractor

This will create a new interactor with the given key. All KeyInteractors are created in the "off" state.

Parameters:
app - your Applet
key - the integer ascii value of the key
 o KeyInteractor
 public KeyInteractor(App app,
                      char key)
Constructor: KeyInteractor

This will create a new interactor with the given character key. It can only be used for keys which have a character value, for example 'j' would be acceptable whereas 'return' would not be.

Parameters:
app - your Applet
key - the character value of the key
 o KeyInteractor
 public KeyInteractor(KeyPressManager kpm,
                      int key)
Constructor: KeyInteractor

This is the constructor to use if an App isn't being used. However, you should really use the App we've made for you.

Parameters:
kpm - the KeyPressManager associated with your Applet
key - the integer ascii value of the key

Methods

 o turnOff
 public void turnOff()
Method: turnOff

This turns off the KeyInteractor.

 o turnOn
 public void turnOn()
Method: turnOn

This turns on the KeyInteractor. You must call this method before the KeyInteractor will register keypresses!

 o keyPress
 public abstract void keyPress()
Method: keyPress

This method is called whenever the Interactor's key is pressed. You must fill in either this or keyRelease (or both) in a subclass for the Interactor to work properly. One of these methods may be empty.

 o keyRelease
 public abstract void keyRelease()
Method: keyReleased

This method is called whenever the Interactor's key is released. You must fill in either this or keyPress (or both) in a subclass for the Interactor to work properly. One of these methods may be empty.


All Packages  Class Hierarchy  This Package  Previous  Next  Index