0 votes

Hello! I want to make an interaction text like "Press F to interact" but with the key that the player has set to be the interaction input, not only F.

I've tried InputMap.get_action_list("interact")[0].as_text() but it doesn't seem to work.

Godot version 3.4.4
in Engine by (54 points)

I've tried it and it works përfectly. Note, that this method doesen't work with physical keys, so you need to make regular key input the first event of an action.

1 Answer

+1 vote
Best answer

There is function to get human-readable key name — OS.get_scancode_string()
If you using physical keys, try this:

OS.get_scancode_string(InputMap.get_action_list("interact")[0].physical_scancode)

Elif you're using regular keys, it's better to use this:

OS.get_scancode_string(InputMap.get_action_list("interact")[0].physical_scancode)

If neither of them works, maybe the problem in something else. Post the code where you trying to use this text.

by (654 points)
edited by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.