KeyboardEventBase<T>
This is the base class for keyboard events.
Read time 3 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: EventBase<T>
- Implements: IDisposable, IKeyboardEvent
public abstract class KeyboardEventBase<T> : EventBase<T>, IDisposable, IKeyboardEvent where T : KeyboardEventBase<T>, new()
Remarks
The typical keyboard event loop is as follows:
-
When a key is pressed, a KeyDownEvent is sent.
-
If the key is held down for a duration determined by the OS, another KeyDownEvent with the same data is sent. While the key is held down, the event is sent repeatedly at a frequency determined by the OS.
-
When the key is released, a KeyUpEvent is sent.
By default, keyboard events trickle down and bubble up. disabled elements won't receive these events.
Refer to the Keyboard events manual page for more information and examples.
Additional Resources: KeyDownEvent, KeyUpEvent
Properties
Property | Description |
|---|---|
| actionKey | Gets a boolean value that indicates whether the platform-specific action key is pressed. |
| altKey | Gets a boolean value that indicates whether the Alt key is pressed. |
| character | Gets the character entered. |
| commandKey | Gets a boolean value that indicates whether the Windows/Cmd key is pressed. |
| ctrlKey | Gets a boolean value that indicates whether the Ctrl key is pressed. |
| keyCode | The key code. |
| modifiers | Gets flags that indicate whether modifier keys (Alt, Ctrl, Shift, Windows/Cmd) are pressed. |
| shiftKey | Gets a boolean value that indicates whether the Shift key is pressed. |
Methods
Method | Description |
|---|---|
| Init | Resets the event members to their initial values. |
Static Methods
Method | Description |
|---|---|
| GetPooled | Gets a keyboard event from the event pool and initializes it with the given values. Use this function instead of creating new events. Events obtained using this method need to be released back to the pool. You can use |