#How to create an InputEventKey in Godot 4?

12 messages · Page 1 of 1 (latest)

dry lake
#

HI!

With Godot 4 the "set_scancode" method disappeared from the gdscript API.
It was used to create an event and eg populate the InputMap singleton:

func _on_create_preset_input_pressed(): var new_input = InputEventKey.new() new_input.set_scancode(KEY_W) InputMap.add_action("move_up") InputMap.action_add_event("move_up",new_input)

I can't see an obvious and straightforward way of doing this in Godot 4 (except maybe with instancing the event and setting directly the key property?).

rose flicker
#

i think scancode was renamed to keycode in godot4? but the functions remain the same to my knowledge, just with a different name

#

i might be wrong about this though

#

but search for keycode in the documentation, it should help

dry lake
#

thanks for replying!
yeah I've seen keycode in the InputEventKey class description.
but it is a property, and not a method.
That's what I said in the last sentence of my question post.
It is maybe the way to go now

vale glade
#

It's a property in 3.5 as well

#

You can still use the setter function if you want, but it's better to use the property

rose flicker
#

and it functions basically the same

#

actually it functions exactly the same if im not wrong

dry lake
#

Ok, I'll try to go with the setter then, thanks for your help guys!🙃