InputMap
Inherits: Object
Description
A singleton that manages all InputEventActions. Manages all InputEventAction which can be created/modified from the project settings menu or in code.
Methods
add_action
void add_action(action: StringName, deadzone: float = 0.2)
Adds an empty action to the InputMap with a configurable deadzone.
The name of the action to add
The deadzone value (default: 0.2)
action_add_event
void action_add_event(action: StringName, event: InputEvent)
Adds an InputEvent to an action. This InputEvent will trigger the action.
action_erase_event
void action_erase_event(action: StringName, event: InputEvent)
Removes an InputEvent from an action.
has_action
bool has_action(action: StringName)
Returns true if the InputMap has a registered action with the given name.
get_actions
StringName[] get_actions()
Returns an array of all actions in the InputMap.
Example Usage
# Add a new action
InputMap.add_action("jump")
# Add a key event to the action
var key_event = InputEventKey.new()
key_event.keycode = KEY_SPACE
InputMap.action_add_event("jump", key_event)
# Check if action exists
if InputMap.has_action("jump"):
print("Jump action exists")
// Add a new action
InputMap.AddAction("jump");
// Add a key event to the action
var keyEvent = new InputEventKey();
keyEvent.Keycode = Key.Space;
InputMap.ActionAddEvent("jump", keyEvent);