Skip to content

Using as_text() on a physical key InputEvent returns an empty string silently #61508

Closed
@Isonzo

Description

Godot version

3.4.4

System information

Linux, Debian 11

Issue description

As of now, when you call the as_text method in a physical key InputEvent, it simply returns an empty string. I would expect it to return either an error telling the user that the method does not function with physical keys, or for it to return the key in that physical position.

All in all, I realize this is a very small issue, and you can currently fix it by simply using keys instead of physical keys, but I think it should do something other than silently return nothing. It should be more obvious something is wrong.

Steps to reproduce

  1. Make a new Godot project
  2. Add an action in the Input Map, in my case I called it test_input
  3. Assign a physical key to that action, in my case I chose A
  4. Create a Control Node
  5. Add a script to the Control Node
extends Control


func _ready():
	var event: InputEvent = InputMap.get_action_list("test_input")[0]
	var faulty_as_text: String = event.as_text()
	print(faulty_as_text)
  1. Save and run the scene

It will not print anything, and if you add a breakpoint, you will see that although there is an InputEvent Object in event, but faulty_as_text remains empty. It will do this silently.

Minimal reproduction project

InputEventBug.zip

This project simply follows the above instructions. Simply run it and behold.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions