Interface IKeyboardEvent
This interface describes the data used by keyboard events.
Namespace: UnityEngine.UIElements
Syntax
public interface IKeyboardEvent
Properties
actionKey
Gets a boolean value that indicates whether the platform-specific action key is pressed. True means the action key is pressed. False means it isn't.
Declaration
bool actionKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
The platform-specific action key is Cmd on macOs, and Ctrl on all other platforms.
altKey
Gets a boolean value that indicates whether the Alt key is pressed. True means the Alt key is pressed. False means it isn't.
Declaration
bool altKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
character
Gets the character entered.
Declaration
char character { get; }
Property Value
Type | Description |
---|---|
Char |
Remarks
This is the character entered when a key is pressed, taking into account the current keyboard layout. For example, pressing the "A" key causes this property to return either "a" or "A", depending on whether the Shift key is pressed at the time. The Shift key itself does not produce a character. When pressed, it returns an empty string.
commandKey
Gets a boolean value that indicates whether the Windows/Cmd key is pressed. True means the Windows/Cmd key is pressed. False means it isn't.
Declaration
bool commandKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
ctrlKey
Gets a boolean value that indicates whether the Ctrl key is pressed. True means the Ctrl key is pressed. False means it isn't.
Declaration
bool ctrlKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
keyCode
The key code.
Declaration
KeyCode keyCode { get; }
Property Value
Type | Description |
---|---|
KeyCode |
Remarks
This is the code of the physical key that was pressed. It doesn't take into account the keyboard layout, and it displays modifier keys, since a key was pressed. For example, pressing the "A" key will cause this property to return KeyCode.A regardless of whether the Shift key is pressed or not. The Shift key itself returns KeyCode.LeftShift since it is a physical key on the keyboard.
modifiers
Gets flags that indicate whether modifier keys (Alt, Ctrl, Shift, Windows/Cmd) are pressed.
Declaration
EventModifiers modifiers { get; }
Property Value
Type | Description |
---|---|
EventModifiers |
shiftKey
Gets a boolean value that indicates whether the Shift key is pressed. True means the Shift key is pressed. False means it isn't.
Declaration
bool shiftKey { get; }
Property Value
Type | Description |
---|---|
Boolean |