godotengine / godotengine/godot-docs

InputEventKey matching logic described in the docs does not match implementation

Open
#11,854 0 comments 0 reactions 0 assignees View on GitHub
area:class reference bug
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version: 4.5.1, 4.3, probably relevant for most 4.X versions**

**Issue description:**

`InputEventKey` documentation states the following:
> When events are compared, properties are checked in the following priority - `keycode`, `physical_keycode` and `unicode`. Events with the first matching value will be considered equal.

To me this sounds like all three fields are compared and if any of them are equal then the events are considered equal. However, in practice the behavior is different: `keycode`, `physical_keycode` and `key_label` (not `unicode`!) are checked on the first event, and the first field that is set is used for comparison. If that field has the same value on the other event then it is considered as matching the first event. (Note that this logic is not symmetric. Swapping the events could change the result if the events have a different fields set.)

Relevant code: https://github.com/godotengine/godot/blob/master/core/input/input_event.cpp#L608-L629

**URL to the documentation page:**

https://docs.godotengine.org/en/stable/classes/class_inputeventkey.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.