• Godot HelpGUI
  • can i ask a different question to is_action_just_pressed to asking which actions are pressed?

So I'd like to ask Input which_actions_are_just_pressed()

Just run the method in loop.


var just_pressed_actions := []
for action in ["a1", "a2"]:
	if Input.is_action_just_pressed(action):
		just_pressed_actions.add(action)

@pkowal1982 said: Just run the method in loop.


var just_pressed_actions := []
for action in ["a1", "a2"]:
	if Input.is_action_just_pressed(action):
		just_pressed_actions.add(action)

well yeh, except i was looking for a built in.

I don't think there is a built in input action log, but I suppose you could always open a proposal on the proposals repo...

You can create global class and put there a function with the signature you want and implementation as above. It will work as in Input. :)

You could do this, but it is bad design and I wouldn't recommend it:

func _input(event):
    print(event.as_text())

Or something like this, which is also a poor design:

func _unhandled_input(event):
    if event is InputEventKey:
        if event.pressed and event.scancode == KEY_ESCAPE:
            get_tree().quit()

yeh but in all this, i would like to ask Input is:

given the state of inputs in the system, please return to me all possible actions that would return is just pressed (or similar).

instead of asking "is this action pressed" i want to ask "which actions are currently just pressed (etc)"

the motivation is for input handling masking. namely i want to ignore some input map actions when I flag that mapped input as masked (by dropping the string name into a dictionary).

Currently I have a large chained if / ifel chain checking for each and every mapped input 'action' and will likely wrap Input.is_just_pressed with a checker and just do it that way.

normally i am used to an input system that uses the Observer pattern. binding response functions to the specific event.

Sorry, yes, I understand what you are asking for now. Here is the code.

extends Node2D

var input_map

func _ready():
	input_map = InputMap.get_actions()
	
func _process(_delta):
	for action in input_map:
		if Input.is_action_just_pressed(action):
			print(action + " was pressed.")

@cybereality said: Sorry, yes, I understand what you are asking for now. Here is the code.

I don't have an issue writing the code. Sorry. It's just me thinking out loud at this point, the functionality would be nice in Input.

10 months later