-
-
Notifications
You must be signed in to change notification settings - Fork 19k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action with modifiers can be released even without being pressed #92228
Comments
Try using |
Try using the event, you shouldn't use
|
There is no accessible method in func _input(event : InputEvent) -> void:
if not event is InputEventKey: return
if event.is_action_pressed("test_action", true): print("pressed")
if event.is_action_released("test_action", true): print("released") In this case the result is the same and it adds one more probably expected issue: |
Again, see the documentation, you need to use |
Okay does it work if you have Did you read the documentation? |
Yes, I read it, but there is no such overload for this function: |
Oh yes sorry that's the case yes, true it should have just the |
So you released all parts of the combination before pressing again, and only |
Yes, for the |
That sounds like it has a problem with registering the modifier keys, but unsure if it's necessarily a bug, I'd suspect that the main key without modifiers is the main part of the event, does it work that way in other software when pressed? The released part might be a bug in that case just specifically Can you try with just I will do some testing on this tomorrow, but I suspect the part where pressed isn't fired when the main (real, i.e. non modifier) isn't pressed last might not be a bug but just a matter of design (to be documented), if you can check other software that'd be a good point of reference |
With the Scenario 1:
Result: action is Scenario 2:
Result: action is Here is the code: func _process(_delta : float) -> void:
if Input.is_action_just_pressed("test_action", true): print("pressed")
if Input.is_action_just_released("test_action", true): print("released") Not sure how does it work with other software, but it can cause some actions to "stick" and never release just if a user pressed it in a different order... Pressing the main key last for event to trigger is perfectly fine, but the fact that event can be only |
With some other software I've confirmed that at least there doing things in the "wrong" order doesn't count, so I think that part is by design, will test the |
Actually, it is much easier to reproduce these bugs (I still think that they are parts of a single bug):
I think, it is quite easy to face this bug when playing a game with these simple two-key combinations and don't understand why it was not found earlier... Could it be something new? Also I'm wondering if it is keyboard specific, but have just one wireless keyboard to test. |
I can confirm this but I'm not sure exactly what to treat it as, the release with inexact will occur when the active key (i.e. non-modifier) is released, the exact only when the full combination is released The action itself is not considered pressed, with So I'd say that the possible bug to discuss here is if the release trigger should be fired on these cases, and when releasing in a different order I think this might be something to document rather than fix Edit: At least on Windows the reason for this is that when pressing Now the question is if the release check should take into consideration if the event was ever pressed, but that's something that might be considered compatibility breaking and would require further evaluation Related: |
Both behaviors I described are unexpected since you may have an action which will be pressed and never released and the other way around - an action which will be released without it beeing ever pressed. Think about this example: a player has a throwable item in his inventory, when an action is pressed - he'll take this item to hands, when the action is released - he'll throw it. But now he can take an item to hands and even after releasing both key it'll still be in his hands or the second option - he can try to throw an item without taking it to hands. P.S.: Maybe we can delete all of our messages starting from the second one up to my message with easier steps to reproduce, so it'll not confuse anyone else who'll read this discussion and try to follow it. |
I'd say that the pressed part is fully as expected and desired, a key combination, i.e. a shortcut, shouldn't fire for these cases IMO. And the release part is something to investigate and decide on, but I suspect it's something that's safest to document and clarify, it risks breaking compatibility in unforeseen ways Further, I'd say that using modifier keys for actions in a game is not something that's necessarily the best solution, most of the time when developing games you have modifier keys modify your actions after the fact and you use other means to detect them The thing I think could be changed, if it's considered safe, would be to add some form of detection for release events where modifier keys being released updates the actions related to them, but that's pretty complicated and might be fragile and undesired, so that's something we'll have to wait for further input on. I think the first step might be to document some of the details of this to help people resolve potential pitfalls, and work on a future solution, and discuss the potential arguments about it
I can hide them as resolved but otherwise they should stay IMO |
Tested versions
Reproducible and found it in v4.2.2.stable.official [15073af]
System information
Godot v4.2.2.stable - Windows 10.0.22631
Issue description
If you have an action with the
Ctrl
and/orShift
modifiers it can be released even without being triggered. Please, check steps to reproduce, it is quite straightforward. The expected behavior: an action can't be released until it is triggered, something like keeping a boolean flag somewhere, enabling it when action triggered and emitting the released event taking into account this flag.Steps to reproduce
_input
,_process
or similar functions as:Output window result (both 3 and 4 steps):
![image](https://private-user-images.githubusercontent.com/17128667/332598142-0a771c62-fd39-40cf-9879-14d68fb7a19f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3MzAwMjgsIm5iZiI6MTcxODcyOTcyOCwicGF0aCI6Ii8xNzEyODY2Ny8zMzI1OTgxNDItMGE3NzFjNjItZmQzOS00MGNmLTk4NzktMTRkNjhmYjdhMTlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE4VDE2NTUyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZiNjJkNTY0ZTg1YWUxNDdkZTY5YTRiODVkNmZmZGZhOGVmMjA1ZDhiNzFmNTIwNzUwYjgwOTI5MjM3MGJhOGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zMwn1RZFtMH0dsDIJ_KZk5BgRDi8GDb1Zia1LiYFgNE)
Minimal reproduction project (MRP)
Godot.zip
The text was updated successfully, but these errors were encountered: