How to get combined keystrokes to register

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 2ndGarrison
:warning: Old Version Published before Godot 3 was released.

Hello,

In the Input Map, you can create actions and set keystrokes or other triggers for those actions. The Input Map also lets you assign combined keystrokes (e.g. Alt+Up, Ctrl+Left). I have an _input function and flags to check if those combined keystrokes are registering. For actions that only require one key, I have no problem registering, but actions that rely on combined keystrokes do not register. Here a bit of code I’m running to demonstrate:

func _input(event):

if(event.type == Input.is_action_pressed("ui_accept")):
	print("UI ACCEPT")

elif(event.type == Input.is_action_pressed("attack")):
	print("ATTACK")

The action “ui_accept” is tied to Enter and Spacebar and a few other things. That registers just fine.
The action “attack” is tied to Ctrl+Right (left control) + (right arrow key). This never registers. Am I doing something wrong to try to handle it?

I try checking the box that’s in the Input Map, and that seems to simply remove the need to press Ctrl and “attack” is triggered by just hitting the right arrow key. I can change the controls for now if this just doesn’t work, but I’d like to be able to use combined keystrokes.

:bust_in_silhouette: Reply From: Hinsbart

It seems your code has some problems, as you’re comparing the event type to a bool.
It should be if event.is_action_pressed("attack"):

For me this triggers the action when mapped to “Ctrl + right”

Indeed! I was using incorrect syntax

Although, I had to use event.is_action(“attack”). That did it!

2ndGarrison | 2016-02-25 16:58