Package event
Class MultiKeyListener
java.lang.Object
java.awt.event.KeyAdapter
event.MultiKeyListener
- All Implemented Interfaces:
Configuration,KeyListener,EventListener
This class maintains a synchronized set of active keys. The KeyEvent.keyCode corresponding to the depressed key
is added to the set when keyPressed is invoked, and removed from the set when keyReleased is invoked.
When polled (getActiveKeys() is invoked), an array of the key codes of all depressed keys is returned.
- Author:
- Krish Pillai
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface common.Configuration
Configuration.Direction -
Field Summary
Fields inherited from interface common.Configuration
AUDIO_DIR, DEFAULT_FRAME_RATE, DRAWABLE_DIR, GAMELOGGER, setViewCallChain -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisable()Sets the listener to disabled status.voidenable()Sets the listener to enabled mode so it can save and retrieve key status.int[]Returns the list of depressed key events or keyCode 0 if no key is pressedbooleanReturns the state of this listener.voidvoidvoidreset()Clears out contents of active key tracking set.Methods inherited from class java.awt.event.KeyAdapter
keyTyped
-
Constructor Details
-
MultiKeyListener
public MultiKeyListener()
-
-
Method Details
-
keyPressed
- Specified by:
keyPressedin interfaceKeyListener- Overrides:
keyPressedin classKeyAdapter
-
keyReleased
- Specified by:
keyReleasedin interfaceKeyListener- Overrides:
keyReleasedin classKeyAdapter
-
getActiveKeys
public int[] getActiveKeys()Returns the list of depressed key events or keyCode 0 if no key is pressed -
isEnabled
public boolean isEnabled()Returns the state of this listener. If disabled, the listener returns a zero for the active keys.- Returns:
- state The active state of the listener
- See Also:
-
enable
public void enable()Sets the listener to enabled mode so it can save and retrieve key status. -
disable
public void disable()Sets the listener to disabled status. Key status will be set to all zeros. -
reset
public void reset()Clears out contents of active key tracking set.
-