eu.webtoolkit.jwt
Class WKeyEvent

java.lang.Object
  extended by eu.webtoolkit.jwt.WKeyEvent
All Implemented Interfaces:
WAbstractEvent

public class WKeyEvent
extends java.lang.Object
implements WAbstractEvent

A class providing details for a keyboard event.

A key event is associated with the WInteractWidget#keyWentDown(), WInteractWidget#keyWentUp() and WInteractWidget#keyPressed() signals.


Constructor Summary
WKeyEvent()
          Default constructor.
 
Method Summary
 WAbstractEvent createFromJSEvent(eu.webtoolkit.jwt.JavaScriptEvent jsEvent)
          Internal method.
 int getCharCode()
          Returns the unicode character code.
 Key getKey()
          Returns the key code key that was pressed or released.
 java.util.EnumSet<KeyboardModifier> getModifiers()
          Returns keyboard modifiers.
 java.lang.String getText()
          The (unicode) text that this key generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WKeyEvent

public WKeyEvent()
Default constructor.

Method Detail

getKey

public Key getKey()
Returns the key code key that was pressed or released.

The key code corresponds to the actual key on the keyboard, rather than the generated character.

All three types of key events provide this information.

See Also:
getModifiers(), getCharCode()

getModifiers

public java.util.EnumSet<KeyboardModifier> getModifiers()
Returns keyboard modifiers.

The result is a logical OR of KeyboardModifier flags.

All three types of key events provide this information.

See Also:
getKey(), getCharCode()

getCharCode

public int getCharCode()
Returns the unicode character code.

This is only defined for a keyPressed event, and returns the unicode character code of a character that is entered.

For the keyWentDown and keyWentUp events, '0' is returned.

The getCharCode() may be different from getKey(). For example, a Key_M key may correspond to 'm' or 'M' character, depending on whether the shift key is pressed simultaneously.

See Also:
getKey(), getText()

getText

public java.lang.String getText()
The (unicode) text that this key generated.

This is only defined for a keyPressed event, and returns a string that holds exactly one unicode character, which corresponds to getCharCode().

For the keyWentDown and keyWentUp events, an empty string is returned.

See Also:
getCharCode()

createFromJSEvent

public WAbstractEvent createFromJSEvent(eu.webtoolkit.jwt.JavaScriptEvent jsEvent)
Description copied from interface: WAbstractEvent
Internal method.

Specified by:
createFromJSEvent in interface WAbstractEvent