change standard keys (up and down) for Left and Right keys

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

The standard keys are up and down to change focus, how do I switch to left and right keys?

func _ready():

(Godot 2.15)

How does your node structure look like? Do you have a Control node with the buttons as children of it?

I use Godot 3 normally, but i downloaded 2.1.5 and the buttons worked out of the box for me. Since that isnt case here you can try to check Scene > Project Settings > Input Map. There you will find some mappings named ui_something. You can look at what buttons they are mapped to and change if you need so.

Elias | 2018-10-28 09:13

The project settings is default. Already tried to add left and right keys in ui_focus_next and ui_focus_prev, tab key works, but left and right no works.


ui_focus_next=[key(Tab), key(Right)]
ui_focus_prev=[key(Tab, S), key(Left)]

Nodes estructure:

If I try to change ui_up and ui_down to left and right, right works and left does not work.


ui_focus_prev=[key(Tab, S)]
ui_up=[jbutton(0, 12), key(Left)]
ui_down=[jbutton(0, 13), key(Right)]

dognew | 2018-10-28 16:26

Depois de muito trabalho, consegui.

Foi necessário alterar todas as teclas, porque o Godot sempre re-adicionava as teclas.

Exemplo, se eu apagasse up, down, left e right, salvava o projeto e saía, ao abrir ele colocava-os de volta.

Ao inverter todas as teclas, forcei-o a não fazer isso.


ui_left=[jbutton(0, 14), key(Up)]
ui_right=[jbutton(0, 15), key(Down)]
ui_up=[jbutton(0, 12), key(Left)]
ui_down=[jbutton(0, 13), key(Right)]

dognew | 2018-10-29 11:59

I am not very experienced with godot myself.
Try this node structure, else
I dont understand at this point what is wrong…

Node structure - Album on Imgur

Should work with default keys, and mouse both godot 3 and 2

Elias | 2018-11-08 20:48

No problem with the structure of nodes.

Godot has standard keys in the configuration, which even though they are deleted, they still exist. To get around this you need to reset with the new values.

Try to create a new project and create this scene:

- Control
    | _ VBoxContainer
         | _ Button1
         | _ Button2
         | _ Button3
         | _ Button4
         | _ Button5

Add a script to the Control node with this code:

extends Control

func_ready ():
# focus on the first button
get_node ("VBoxContainer / Button"). grab_focus ()

In project settings, set the main scene and delete all input maps. Run the project!

You’ll see that even with everything off, the keys work.

dognew | 2018-11-22 06:07