Class CancelKey
The keys that cancel, close and back out: Escape, and ~ (the backquote key) everywhere except a text field.
public static class CancelKey
- Inheritance
-
CancelKey
- Inherited Members
Remarks
~ exists because of the browser. A web build cannot have Escape: it always releases the pointer lock and leaves fullscreen, no page can cancel that, and the browser often does not deliver the key at all. Escape is kept beside it for the desktop client and for the times a browser does pass it through.
While the player is typing, only Escape counts. ~ and ` are characters, and a field that ate them could not hold a password containing one, or a chat line. Typing also means the cursor is already free, which is when a browser lets Escape through.
The same pair is bound in the input asset to Player/Cancel and Player/CloseLastUI, whose handlers apply the same rule through InputControlHasFocus(UITKControl); see PlayerInputController.
Fields
BackquoteControlPath
Input System control path of the ~ key, as bound in PlayerControls.inputactions.
public const string BackquoteControlPath = "<Keyboard>/backquote"
Field Value
EscapeControlPath
Input System control path of Escape.
public const string EscapeControlPath = "<Keyboard>/escape"
Field Value
Methods
IsInTextField(VisualElement)
True when element is a text input or sits inside one.
public static bool IsInTextField(VisualElement element)
Parameters
elementVisualElement
Returns
Remarks
A TextField delegates focus to its inner text element, so a key event targets that child; walking up catches both. Matched by USS class rather than type so every field type (TextField, IntegerField, ...) is covered, and Buttons and Labels — which are TextElements too — are not.
Matches(KeyDownEvent)
True when a key press should cancel: Escape always, ~ unless it was pressed inside a text field.
public static bool Matches(KeyDownEvent evt)
Parameters
evtKeyDownEventThe key-down event a panel received.