Navigation
API > API/Runtime > API/Runtime/InteractiveToolsFramework
UKeyInputBehavior provides a keyboard capturing behavior that works with single or multiple keys. Provided with a single key, the behavior triggers OnKeyPressed and OnKeyReleased events upon seeing the target key pressed down and released for the first time, ignoring any other key presses. When provided with multiple keys, the Behavior has variable behavior depending on whether bRequireAllKeys is set.
If true, the behavior sequence is as follows:
Initiate capture when any of the target keys are pressed.
Continue capture until all target keys are pressed simultaneously
Upon seeing the last key to complete the full set of target keys, issue an OnKeyPressed for whichever key completed the requirement. 3b. If any of the target keys are released after the full set was pressed, issue an OnKeyReleased for whichever key was released, then end Capture.
If at any point all target keys are released after capture begins, end capture.
If false, the behavior sequence is as follows:
Initiate capture when any of the target keys are pressed.
Continue capture while any of the target keys are still pressed.
Issue an OnKeyPressed for any target key pressed during the capture period.
Issue an OnKeyReleased for any target key released during the capture period.
If at any point all target keys are released, end capture.
| Name | UKeyInputBehavior |
| Type | class |
| Header File | /Engine/Source/Runtime/InteractiveToolsFramework/Public/BaseBehaviors/KeyInputBehavior.h |
| Include Path | #include "BaseBehaviors/KeyInputBehavior.h" |
Syntax
UCLASS (MinimalAPI)
class UKeyInputBehavior : public UInputBehavior
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UInputBehavior → UKeyInputBehavior
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UKeyInputBehavior() |
BaseBehaviors/KeyInputBehavior.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bRequireAllKeys | bool | If true, behavior requires all keys provided at initialization to be active at the same time in order to count as a "key down" event. | BaseBehaviors/KeyInputBehavior.h | |
| ModifierCheckFunc | TFunction< bool(const FInputDeviceState &)> | WantsCapture() will only return capture request if this function returns true (or is null) | BaseBehaviors/KeyInputBehavior.h | |
| Modifiers | FInputBehaviorModifierStates | The modifier set for this behavior | BaseBehaviors/KeyInputBehavior.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bAllKeysSeenPressed | bool | BaseBehaviors/KeyInputBehavior.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void Initialize
(
IKeyInputBehaviorTarget* Target, |
Initialize this behavior with the given Target | BaseBehaviors/KeyInputBehavior.h | |
virtual void Initialize
(
IKeyInputBehaviorTarget* Target, |
Initialize this behavior with the given Target | BaseBehaviors/KeyInputBehavior.h |
Overridden from UInputBehavior
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual FInputCaptureUpdate BeginCapture
(
const FInputDeviceState& InputState, |
Called after WantsCapture() returns a capture request that was accepted | BaseBehaviors/KeyInputBehavior.h | |
virtual void ForceEndCapture
(
const FInputCaptureData& CaptureData |
If this is called, the Behavior has forcibly lost capture (eg due to app losing focus for example) and needs to clean up accordingly | BaseBehaviors/KeyInputBehavior.h | |
virtual EInputDevices GetSupportedDevices() |
Which device types does this Behavior support | BaseBehaviors/KeyInputBehavior.h | |
virtual FInputCaptureUpdate UpdateCapture
(
const FInputDeviceState& InputState, |
Called for each new input event during a capture sequence. | BaseBehaviors/KeyInputBehavior.h | |
virtual FInputCaptureRequest WantsCapture
(
const FInputDeviceState& Input |
UInputBehavior implementation. | BaseBehaviors/KeyInputBehavior.h |