diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index 5c4dc8e65da..48a68042909 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -79,7 +79,25 @@ Represents the physical location of a key on the 101/102-key US QWERTY keyboard, which corresponds to one of the [enum Key] constants. - To get a human-readable representation of the [InputEventKey], use [code]OS.get_keycode_string(event.keycode)[/code] where [code]event[/code] is the [InputEventKey]. + To get a human-readable representation of the [InputEventKey], use [method OS.get_keycode_string] in combination with [method DisplayServer.keyboard_get_keycode_from_physical]: + [codeblocks] + [gdscript] + func _input(event): + if event is InputEventKey: + var keycode = DisplayServer.keyboard_get_keycode_from_physical(event.physical_keycode) + print(OS.get_keycode_string(keycode)) + [/gdscript] + [csharp] + public override void _Input(InputEvent @event) + { + if (@event is InputEventKey inputEventKey) + { + var keycode = DisplayServer.KeyboardGetKeycodeFromPhysical(inputEventKey.PhysicalKeycode); + GD.Print(OS.GetKeycodeString(keycode)); + } + } + [/csharp] + [/codeblocks] If [code]true[/code], the key's state is pressed. If [code]false[/code], the key's state is released.