public abstract class KeyboardEvent extends ComponentEvent<Component>
source| Constructor and Description |
|---|
KeyboardEvent(Component source,
boolean fromClient,
String key,
String code,
int location,
boolean ctrlKey,
boolean shiftKey,
boolean altKey,
boolean metaKey,
boolean repeat,
boolean composing)
Creates a new keyboard event.
|
KeyboardEvent(Component source,
String key)
Creates a new server-side keyboard event with no additional information.
|
KeyboardEvent(Component source,
String key,
String code)
Creates a new server-side keyboard event with no additional information.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<Key> |
getCode()
Gets the code of the event.
|
Key |
getKey()
Gets the key of the event.
|
KeyLocation |
getLocation()
Gets the
KeyLocation of the event. |
Set<KeyModifier> |
getModifiers()
Gets the set of
KeyModifier of the event. |
boolean |
isComposing()
Checks whether the key event occurred as part of a composition session.
|
boolean |
isRepeat()
Checks whether the key has been pressed in a sustained manner.
|
getSource, isFromClient, unregisterListenertoStringpublic KeyboardEvent(Component source, boolean fromClient, String key, String code, int location, boolean ctrlKey, boolean shiftKey, boolean altKey, boolean metaKey, boolean repeat, boolean composing)
source - the component that fired the eventfromClient - true if the event was originally fired on the
client, false if the event originates from
server-side logickey - the string value representing the keycode - the string value representing the code (nullable)location - the integer value representing the location of the keyctrlKey - true if the control key was down when the event
was fired, false otherwiseshiftKey - true if the shift key was down when the event was
fired, false otherwisealtKey - true if the alt key was down when the event was
fired, false otherwisemetaKey - true if the meta key was down when the event was
fired, false otherwiserepeat - true if the key has been pressed in a sustained
mannercomposing - true if the key event occurred as part of a
composition sessionpublic KeyboardEvent(Component source, String key)
source - the component that fired the eventkey - the key for this eventpublic Optional<Key> getCode()
null value will be given instead.Keypublic KeyLocation getLocation()
KeyLocation of the event.KeyLocation of the eventpublic boolean isRepeat()
true if the key has been pressed in a sustained
mannerpublic boolean isComposing()
true if the key event occurred as part of a
composition sessionpublic Set<KeyModifier> getModifiers()
KeyModifier of the event.KeyModifierCopyright © 2025. All rights reserved.