Package totalcross.ui.event
Class KeyEvent
- java.lang.Object
-
- totalcross.ui.event.Event<KeyListener>
-
- totalcross.ui.event.KeyEvent
-
public class KeyEvent extends Event<KeyListener>
KeyEvent is a key press event.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.event.Event
Event.Type<H>
-
-
Field Summary
Fields Modifier and Type Field Description static intACTION_KEY_PRESSThe event type for a focus being transfered to this control with the ENTER or ACTION keys.intkeyThe key pressed or entered by other means (grafitti input).static intKEY_PRESSThe event type for a key press event.intmodifiersThe state of the modifier keys when the event occured.static intSPECIAL_KEY_PRESSThe event type for a device key press event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch(KeyListener listener)booleanisActionKey()Returns true if the key press is an ACTION or ENTER one.booleanisDownKey()Returns true if the key press is any kind of the possible ones that means Down.booleanisNextKey()Returns true if the key press is any kind of the possible ones that means forward (TAB, PAGE_DOWN, DOWN, RIGHT, etc).booleanisPrevKey()Returns true if the key press is any kind of the possible ones that means previous (PAGE_UP, UP, LEFT, etc)booleanisUpKey()Returns true if the key press is any kind of the possible ones that means UP.java.lang.StringtoString()-
Methods inherited from class totalcross.ui.event.Event
clearQueue, getNextAvailableEventId, isAvailable, touch
-
-
-
-
Field Detail
-
KEY_PRESS
public static final int KEY_PRESS
The event type for a key press event. Device keys are handled in the SPECIAL_KEY_PRESS event.- See Also:
- Constant Field Values
-
ACTION_KEY_PRESS
public static final int ACTION_KEY_PRESS
The event type for a focus being transfered to this control with the ENTER or ACTION keys.- See Also:
- Constant Field Values
-
SPECIAL_KEY_PRESS
public static final int SPECIAL_KEY_PRESS
The event type for a device key press event. Note that some keys are posted only when they are released.- See Also:
- Constant Field Values
-
key
public int key
The key pressed or entered by other means (grafitti input). This is either a normal character key (if the value is < 70000) or one of the special keys defined in the DeviceKeys interface.- See Also:
SpecialKeys
-
modifiers
public int modifiers
The state of the modifier keys when the event occured. This is a OR'ed combination of the modifiers present in the DeviceKeys interface.- See Also:
SpecialKeys
-
-
Constructor Detail
-
KeyEvent
public KeyEvent()
Constructs a KeyEvent, assigning the type as KEY_PRESS.
-
KeyEvent
public KeyEvent(int type, int key, int modifiers)Creates a new instance of KeyEvent with the specified type, key and modifiers.- Parameters:
type- the KeyEvent type, must be eitherKEY_PRESS,ACTION_KEY_PRESSorSPECIAL_KEY_PRESSkey- the input keymodifiers- state of the modifier keys for this event- Throws:
java.lang.IllegalArgumentException- if the type argument is not equal toKEY_PRESS,ACTION_KEY_PRESSorSPECIAL_KEY_PRESS.- Since:
- TotalCross 1.33
- See Also:
KEY_PRESS,ACTION_KEY_PRESS,SPECIAL_KEY_PRESS
-
-
Method Detail
-
isActionKey
public boolean isActionKey()
Returns true if the key press is an ACTION or ENTER one.- Since:
- SuperWaba 5.5
-
isUpKey
public boolean isUpKey()
Returns true if the key press is any kind of the possible ones that means UP.- Since:
- SuperWaba 5.5
-
isDownKey
public boolean isDownKey()
Returns true if the key press is any kind of the possible ones that means Down.- Since:
- SuperWaba 5.5
-
isNextKey
public boolean isNextKey()
Returns true if the key press is any kind of the possible ones that means forward (TAB, PAGE_DOWN, DOWN, RIGHT, etc).- Since:
- SuperWaba 5.5
-
isPrevKey
public boolean isPrevKey()
Returns true if the key press is any kind of the possible ones that means previous (PAGE_UP, UP, LEFT, etc)- Since:
- SuperWaba 5.5
-
toString
public java.lang.String toString()
- Overrides:
toStringin classEvent<KeyListener>
-
dispatch
public void dispatch(KeyListener listener)
- Specified by:
dispatchin classEvent<KeyListener>
-
-