Doesn't run code when two key pressed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hard

func _input(event):
if event.is_action_pressed(“ui_up”) && event.is_action_pressed(“ui_left”): //doesn’t work
// both have underscore [ui_up,ui_left]

if event.is_action_pressed(“ui_up”): //worked

:bust_in_silhouette: Reply From: spaceyjase

You’re using event driven code; it won’t fire for both events here (that is, including both events - likely one after the other). The event will hold one (and only one) input event (and/or modifiers, etc).

You could change the other check to Input, e.g.

if event.is_action_pressed("ui_up") && Input.is_action_pressed("ui_left"):
    # code

…and likewise for the ui_left event and pressed ui_up. Although I don’t know what you’re doing with the code here; likely you really want to apply some movement independently per frame; e.g. ui_up only applies some up value; ui_left some left; both should be applied when appropriate.