|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.KeyPressReleaseListener
The class KeyPressReleaseListener
implements a KeyListener that tracks
the pressed-released state of keyboard keys. It
is possible to track all key codes from the Java
class KeyEvent or to supply a list
of which particular key codes to track.
This class makes a best effort to track multiple simultaneous key press situations. We know however that in some cases the hardware does not deliver the required information to Java if "too many" keys are pressed. Let us explain.
We have run experiments using a laptop with an external USB keyboard attached. Here are some of the problems encountered.
The bottom line is that software cannot process what the hardware and operating system refuse to deliver as proper and timely events.
Despite these significant issues, we felt that
KeyPressReleaseListener is a valuable
class for certain student software projects so we
have decided to include it in JPT as is.
| Field Summary | |
private BooleanStateArray |
bsa
The structure to maintain the pressed-released state. |
| Constructor Summary | |
KeyPressReleaseListener()
Initializes the internal state structure with all key codes from the KeyEvent class. |
|
KeyPressReleaseListener(int[] list)
Initializes the internal state structure with the given list of key codes which should be a subset of the KeyEvent class key codes. |
|
| Method Summary | |
boolean |
getState(int keycode)
Returns the boolean state of the given key where true = pressed and false = released. |
void |
keyPressed(KeyEvent e)
Stores the event key code state as true. |
void |
keyReleased(KeyEvent e)
Stores the event key code state as false. |
void |
keyTyped(KeyEvent e)
Does nothing. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private BooleanStateArray bsa
| Constructor Detail |
public KeyPressReleaseListener()
public KeyPressReleaseListener(int[] list)
list - the list of key codes to track| Method Detail |
public void keyPressed(KeyEvent e)
keyPressed in interface KeyListenere - the KeyEvent sent to this listenerpublic void keyReleased(KeyEvent e)
keyReleased in interface KeyListenere - the KeyEvent sent to this listenerpublic void keyTyped(KeyEvent e)
keyTyped in interface KeyListenerpublic boolean getState(int keycode)
Returns the boolean state of the given key where true = pressed and false = released.
Returns false if the key was not given in the list provided to the constructor since that key is not being tracked.
keycode - the keycode whose pressed-released
state is being queried
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||