Repository: godotengine/godot (language: cpp)

Issue:
Inconsistent info reported in InputEventKey
### Tested versions

- Reproducible in: v4.2.2.stable.official [15073afe3], v4.3.dev6.official [89850d553]

### System information

Godot v4.3.dev6 - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (NVIDIA; 31.0.15.5123) - AMD Ryzen 9 7950X 16-Core Processor (32 Threads)

### Issue description

When receiving an InputEventKey pressed for a modifier key input (eg. CTRL), the event responds to `is_pressed()` with true, but the member variable `ctrl_pressed` will contain false.  This creates a situation where the data reported is inconsistent with itself.

I would expect a key event for a modifier being pressed to have that data consistent across the whole event (ie. `ctrl_pressed` should also report true, as should `is_command_or_control_pressed()`).

This issue applies to all modifier keys, CTRL is just being used as an example.

### Steps to reproduce

1. Load the MRP and run the game.
2. Press control, and see that the log says key_event.is_pressed() is true while the value of key_event.ctrl_pressed remains false.

Optionally, also play with pressing and holding Shift either before or after starting to hold CTRL, and see that the result in key_event.ctrl_pressed is reported differently depending on which key was pressed first.

### Minimal reproduction project (MRP)

[ctrl_pressed.zip](https://github.com/godotengine/godot/files/15211648/ctrl_pressed.zip)



Discussion / hints:
I'd say this is a matter of definition, I'd say a modifier key is only a modifier when it modifies another key, not when it's alone

This is by design, but that doesn't mean it's fixed, but this isn't due to an oversight but by choice, see for example:
https://github.com/godotengine/godot/blob/7ebc866418b075df58cbe4e31fcf8b0c3acd70a1/platform/windows/display_server_windows.cpp#L4702-L4706

This should however at minimum be documented more clearly

Edit: while I haven't confirmed it myself looking at some comments online this seems to be the same behaviour as in Qt, and possibly other interfaces
I can understand this argument, and if it's done intentionally and desired, I won't press the issue. It merely surprised me enough to merit a report.
I agree adjusting the documentation would help reduce the surprise.

Fix patch:
diff --git a/doc/classes/InputEventWithModifiers.xml b/doc/classes/InputEventWithModifiers.xml
index 5c018b0c56d1..1434f3411573 100644
--- a/doc/classes/InputEventWithModifiers.xml
+++ b/doc/classes/InputEventWithModifiers.xml
@@ -5,6 +5,7 @@
 	</brief_description>
 	<description>
 		Stores information about mouse, keyboard, and touch gesture input events. This includes information about which modifier keys are pressed, such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See [method Node._input].
+		[b]Note:[/b] Modifier keys are considered modifiers only when used in combination with another key. As a result, their corresponding member variables, such as [member ctrl_pressed], will return [code]false[/code] if the key is pressed on its own.
 	</description>
 	<tutorials>
 		<link title="Using InputEvent">$DOCS_URL/tutorials/inputs/inputevent.html</link>


Test patch: