Skip to content

Conversation

@xuhuisheng
Copy link
Contributor

@xuhuisheng xuhuisheng commented Oct 20, 2025

Issue Description

This is an interesting issue, but I think we should discuss about whether we need to deal with it.

Currently, the combination key behavior is as follows:

  1. Press and hold W, InputEventKey: keycode=87 (W), mods=none, pressed=true
  2. Press and hold Shift, InputEventKey: keycode=4194325 (Shift), mods=none, pressed=true
  3. InputEventKey: keycode=87 (W), mods=shift, pressed=true, please notice there is mods=shift
  4. Release Shift, InputEventKey: keycode=4194325 (Shift), mods=none, pressed=false
  5. Release W, InputEventKey: keycode=87 (W), mods=none, pressed=false

Relevant result of is_input_pressed() is:

  1. W
  2. W, Shift
  3. W, Shift, Shift+W
  4. W, Shift+W
  5. none

Because InputEvent used keycode to decide which InputEvent may be pressed, and the modifier of InputEvent must cover the whole modifer of predefined action, it can be decided to pressed. But when the keycode related key released, it doesnot evaluate this modifier, just equals keycode will decide to whole combination key released.

Let us see another scenario:

  1. Press and hold Shift, InputEventKey: keycode=4194325 (Shift), mods=none, pressed=true
  2. Press and hold W, InputEventKey: keycode=87 (W), mods=shift, pressed=true, please notice there is mods=shift
  3. Release W, InputEventKey: keycode=87 (W), mods=shift, pressed=false, please notice there is mods=shift
  4. Release Shift, InputEventKey: keycode=4194325 (Shift), mods=none, pressed=false

Relevant result of is_input_pressed() is:

  1. Shift
  2. W, Shift, Shift+W
  3. Shift
  4. none

As described above. The pressed condition is the same, the whole modifier have to cover the action. But the shift is trivial. The keycode is more important to the combination key when released.

Solution

We should discuss about whether we should modify the behavior of releasing condition.

I updated to decide whether requested modifier is part of action modifier when key released. It can change this first scenario to better result.

  1. W
  2. W, Shift
  3. W, Shift, Shift+W
  4. W
  5. none

But I am not sure if this change has any other impact. e.g. it may cause Shift+W combination key triggered multiple-time released events.

It is appreciate for any advice. Thank you.

@xuhuisheng xuhuisheng requested a review from a team as a code owner October 20, 2025 15:29
@xuhuisheng xuhuisheng requested a review from a team as a code owner October 20, 2025 17:21
@bruvzg bruvzg added this to the 4.6 milestone Oct 20, 2025
@bruvzg bruvzg self-requested a review October 20, 2025 17:43
@bruvzg
Copy link
Member

bruvzg commented Oct 28, 2025

Seems like it doesn't work, Shift is still stuck in the same way as before.

@xuhuisheng
Copy link
Contributor Author

@bruvzg
What platform are you using? I tested on ubuntu-24.04.

@bruvzg
Copy link
Member

bruvzg commented Oct 28, 2025

I have tested it on macOS only, will check on Windows and Linux later.

@xuhuisheng
Copy link
Contributor Author

xuhuisheng commented Oct 28, 2025

@bruvzg
I found the issue isnot resolved in ubuntu-24.04, either. I will go to verify if I made something wrong.
Thanks for testing.

@xuhuisheng xuhuisheng closed this Oct 28, 2025
@xuhuisheng xuhuisheng reopened this Oct 28, 2025
@xuhuisheng
Copy link
Contributor Author

xuhuisheng commented Oct 28, 2025

@bruvzg

I am sorry. I totally cannot remember how I tested this patch. I even write a testcase for the boundary situation. But the implement is wrong. When released shift, the modifier mask is always zero.

So I calculate the key_modifier for shift/ctrl/meta/alt when key code mismatched.

I test passed locally on Ubuntu-24.04. Thank you for your time.

input.webm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input Modifiers don't properly apply

2 participants