Skip to content
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

[Modifier + Key] action is fired when pressing Key without modifier #34502

Open
SleepProgger opened this issue Dec 21, 2019 · 4 comments
Open

Comments

@SleepProgger
Copy link

Sorry if this should be a duplicate. Its not that easy finding anything in 5000+ open issues tho.

Godot version:
3.1.2

OS/device including version:
Manjaro with kernel 5.4.2

Issue description:
When creating an action with a modifier key event.is_action_released() returns true when only pressing the key without the modifier.
There are a lot of issues with the opposite problem, but i didn't found one about this way around.

As seen in the relevant code (https://github.com/godotengine/godot/blob/3.1/core/os/input_event.cpp#L312):

bool match = get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);

modifiers are simply ignored when the key isn't pressed (key released).

Steps to reproduce:
Create action with an modifier. Ctrl+A for example.
In an _unhandled_input function do:

if event.is_action_released("my_ctrl_a_action"):
    print("ctrl+a action called")

and press "A".

@SleepProgger
Copy link
Author

Still present in 3.2.1

@Janglee123
Copy link
Contributor

Changing condition to this works, but don't know if it would break stuff.

bool match = get_scancode() == key->get_scancode() && (code & event_code) == code;

Lunatoid added a commit to Lunatoid/godot that referenced this issue Jan 20, 2021
Should fix godotengine#34502, now it checks if the keycode matches
and seperately if the modifiers also match.

Let's say we have an action that is bound to CTRL+"A"
This means that holding CTRL and then pressing and
releasing "A" will now appropiately fire the events.

One thing to note is that pressing CTRL+"A" and then
releasing CTRL while still holding "A"  does not fire
the release event.
@akien-mga
Copy link
Member

This is still reproducible in 4.0 RC 1.

@didier-v
Copy link
Contributor

didier-v commented Feb 7, 2024

Still present in 4.1.
Also affects Input.is_action_just_released.

In 4.2 it is worse.
I tested with two actions down and alt_down.
action_settings

	if Input.is_action_just_released("down"):
		print("down")
	if Input.is_action_just_released("alt_down"):
		print("alt_down")

prints "down" and "alt_down", with or without alt pressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants