public final class KeyEvent extends Event
Event.Type.KEY_PRESSED
or
Event.Type.KEY_RELEASED
.Event.Type
Modifier and Type | Field and Description |
---|---|
boolean |
alt
true if an ALT key (left or right) was pressed when the event occured,
false if not. |
boolean |
control
true if a CTRL key (left or right) was pressed when the event occured,
false if not. |
Keyboard.Key |
key
The code of the key that was pressed or released.
|
boolean |
shift
true if a SHIFT key (left or right) was pressed when the event occured,
false if not. |
boolean |
system
true if a system key was pressed when the event occured,
false if not. |
Constructor and Description |
---|
KeyEvent(int type,
int keyCode,
boolean alt,
boolean shift,
boolean control,
boolean system)
Constructs a new key event.
|
Modifier and Type | Method and Description |
---|---|
KeyEvent |
asKeyEvent()
Attempts to cast this event to a
KeyEvent . |
asJoystickButtonEvent, asJoystickEvent, asJoystickMoveEvent, asMouseButtonEvent, asMouseEvent, asMouseWheelEvent, asSizeEvent, asTextEvent
public final Keyboard.Key key
public final boolean alt
true
if an ALT
key (left or right) was pressed when the event occured,
false
if not.public final boolean shift
true
if a SHIFT
key (left or right) was pressed when the event occured,
false
if not.public final boolean control
true
if a CTRL
key (left or right) was pressed when the event occured,
false
if not.public final boolean system
true
if a system key was pressed when the event occured,
false
if not.public KeyEvent(int type, int keyCode, boolean alt, boolean shift, boolean control, boolean system)
type
- the type of the event.
This must be a valid ordinal in the Event.Type
enumeration.keyCode
- the code of the key that was pressed.
This must be a valid ordinal in the Keyboard.Key
enumeration.alt
- true
to indicate that an ALT
key was pressed.shift
- true
to indicate that a SHIFT
key was pressed.control
- true
to indicate that a CTRL
key was pressed.system
- true
to indicate that a system key was pressed.public KeyEvent asKeyEvent()
Event
KeyEvent
.asKeyEvent
in class Event
KeyEvent
if its type is either
Event.Type.KEY_PRESSED
or Event.Type.KEY_RELEASED
,
null
otherwise.