com.miginfocom.util
Class KeyEventSequencer

java.lang.Object
  extended by com.miginfocom.util.KeyEventSequencer
All Implemented Interfaces:
java.awt.KeyEventDispatcher

public class KeyEventSequencer
extends java.lang.Object
implements java.awt.KeyEventDispatcher

A class that can be made to listen to all key events within the virtual machine and maintain the the keys that are currently pressed. It does not consume any key events.


Method Summary
 boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
           
static KeySequence getCurrentSequence()
          Returns the key sequence that is pressed right now.
static boolean isDown(int keyCode)
          Returns if the key is currently pressed
static boolean isDown(java.util.List keyCodes, boolean checkOrder)
          Returns if the key is currently pressed
static void start()
          Starts the sequncer, if not already started.
static void stop()
          Reduces the invocation count by one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public static void start()
Starts the sequncer, if not already started. Adds one to the start count. The sequencer won't be stopped until that count comes down to zero again.


stop

public static void stop()
Reduces the invocation count by one. If it reached zero the sequencer is stopped. If already at zero an IllegalStateException will be thrown.


isDown

public static boolean isDown(int keyCode)
Returns if the key is currently pressed

Parameters:
keyCode - The key to test. 'f' will work, as will KeyEvent.VK_SHIFT.
Returns:
If the key is currently pressed

getCurrentSequence

public static KeySequence getCurrentSequence()
Returns the key sequence that is pressed right now.

Returns:
The key sequence that is pressed right now. Never null.

isDown

public static boolean isDown(java.util.List keyCodes,
                             boolean checkOrder)
Returns if the key is currently pressed

Parameters:
keyCodes - The keys to test. 'f' will work, as will KeyEvent.VK_SHIFT. Not null.
checkOrder - If true the order in which the keys where pressed must be same as well.
Returns:
If the key is currently pressed

dispatchKeyEvent

public boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
Specified by:
dispatchKeyEvent in interface java.awt.KeyEventDispatcher


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.