For modders, hotkeys in Blueprints provide a way to execute additional logic when specific keys are pressed.
This feature allows for the creation of custom in-game actions, shortcuts, and debug commands, enhancing the player's experience and testing efficiency.
The easiest way to monitor if a specific key is pressed is by using the following logic shown:
What if we have more keys to monitor? use Sequence
flow node.
Tip
Useful for single use or togglable operations, like toggling a flashlight on and off.
The more keys you monitor, the messier it gets and to prevent "spaghetti code", it is recommended to use a custom Macro.
- Left side panel, under the Macros section, press the
+
to create a new Macro and name itKeyPressed
.
- Create the shown inputs and outputs in the Macro.
- Create the same logic as we had in the event graph, and connect the nodes as shown in the image.
- Now we can use the macro in our event graph.
It's much cleaner and easier to read and maintain.
If you need to monitor whenever a key is being pressed and released, create the following macro:
Tip
Useful for toggling actions while holding the key, like using an in-game tool while a key is being pressed.
If you need to monitor the time a certain key is being held down, create the following macro:
Tip
Useful for events where the player needs to hold a key for X amount of seconds, like opening a door or quick-action sequences in cinematics.