0 votes

I want to create an action say "moveup" when I press KEYW but I don't want to create it in the project settings is there any way to assign KEYW to action "moveup" in gdscript?

asked Jun 3, 2019 in Engine by Thakee Nathees (239 points)

1 Answer

0 votes
Best answer

Try this:

# create the action 'move_up' if not already
if not InputMap.has_action('move_up'):

var event = InputEventKey.new()
event.scancode = KEY_W
InputMap.action_add_event('move_up', event)

Check out this Input Mapping demo for more advanced key mapping.

answered Jun 3, 2019 by Dlean Jeans (3,917 points)
selected Jun 6, 2019 by Thakee Nathees
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.