Class WKeyEvent
- All Implemented Interfaces:
WAbstractEvent
public class WKeyEvent extends java.lang.Object implements WAbstractEvent
A key event is associated with the WInteractWidget.keyWentDown()
, WInteractWidget.keyWentUp()
and WInteractWidget.keyPressed()
signals.
-
Constructor Summary
Constructors Constructor Description WKeyEvent()
Default constructor. -
Method Summary
Modifier and Type Method Description 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 Details
-
WKeyEvent
public WKeyEvent()Default constructor.
-
-
Method Details
-
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
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
WInteractWidget.keyPressed()
event, and returns the unicode character code point of a character that is entered.For the
WInteractWidget.keyWentDown()
andWInteractWidget.keyWentUp()
events, '0' is returned.The
getCharCode()
may be different fromgetKey()
. For example, aKey.Key_M
key may correspond to 'm' or 'M' character, depending on whether the shift key is pressed simultaneously. -
getText
public java.lang.String getText()The (unicode) text that this key generated.This is only defined for a
WInteractWidget.keyPressed()
event, and returns a string that holds exactly one unicode character, which corresponds togetCharCode()
.For the
WInteractWidget.keyWentDown()
andWInteractWidget.keyWentUp()
events, an empty string is returned.- See Also:
getCharCode()
-
createFromJSEvent
Description copied from interface:WAbstractEvent
Internal method.- Specified by:
createFromJSEvent
in interfaceWAbstractEvent
-