Class KeyboardEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.flow.component.ComponentEvent<Component>
-
- com.vaadin.flow.component.internal.KeyboardEvent
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
KeyDownEvent,KeyPressEvent,KeyUpEvent
public abstract class KeyboardEvent extends ComponentEvent<Component>
Abstract class for keyboard events.- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Key>getCode()Gets the code of the event.KeygetKey()Gets the key of the event.KeyLocationgetLocation()Gets theKeyLocationof the event.Set<KeyModifier>getModifiers()Gets the set ofKeyModifierof the event.booleanisComposing()Checks whether the key event occurred as part of a composition session.booleanisRepeat()Checks whether the key has been pressed in a sustained manner.-
Methods inherited from class com.vaadin.flow.component.ComponentEvent
getSource, isFromClient, unregisterListener
-
Methods inherited from class java.util.EventObject
toString
-
-
-
-
Constructor Detail
-
KeyboardEvent
public 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.- Parameters:
source- the component that fired the eventfromClient-trueif the event was originally fired on the client,falseif 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-trueif the control key was down when the event was fired,falseotherwiseshiftKey-trueif the shift key was down when the event was fired,falseotherwisealtKey-trueif the alt key was down when the event was fired,falseotherwisemetaKey-trueif the meta key was down when the event was fired,falseotherwiserepeat-trueif the key has been pressed in a sustained mannercomposing-trueif the key event occurred as part of a composition session
-
KeyboardEvent
public KeyboardEvent(Component source, String key)
Creates a new server-side keyboard event with no additional information.- Parameters:
source- the component that fired the eventkey- the key for this event
-
-
Method Detail
-
getCode
public Optional<Key> getCode()
Gets the code of the event. If the event did not contain a valid code, an empty Optional will be given.- Returns:
- the optional code of the event as a
Key
-
getLocation
public KeyLocation getLocation()
Gets theKeyLocationof the event.- Returns:
- the
KeyLocationof the event
-
isRepeat
public boolean isRepeat()
Checks whether the key has been pressed in a sustained manner.- Returns:
trueif the key has been pressed in a sustained manner
-
isComposing
public boolean isComposing()
Checks whether the key event occurred as part of a composition session.- Returns:
trueif the key event occurred as part of a composition session
-
getModifiers
public Set<KeyModifier> getModifiers()
Gets the set ofKeyModifierof the event.- Returns:
- the set of
KeyModifier
-
-