- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 23.5k
 
Fix Input modifiers released condition #111850
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
base: master
Are you sure you want to change the base?
Conversation
| 
           Seems like it doesn't work,   | 
    
| 
           @bruvzg  | 
    
| 
           I have tested it on macOS only, will check on Windows and Linux later.  | 
    
| 
           @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  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 | 
    
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:
W,InputEventKey: keycode=87 (W), mods=none, pressed=trueShift,InputEventKey: keycode=4194325 (Shift), mods=none, pressed=trueInputEventKey: keycode=87 (W), mods=shift, pressed=true, please notice there is mods=shiftShift,InputEventKey: keycode=4194325 (Shift), mods=none, pressed=falseW,InputEventKey: keycode=87 (W), mods=none, pressed=falseRelevant result of
is_input_pressed()is:Because
InputEventusedkeycodeto decide whichInputEventmay be pressed, and the modifier ofInputEventmust cover the whole modifer of predefined action, it can be decided to pressed. But when thekeycoderelated key released, it doesnot evaluate this modifier, just equalskeycodewill decide to whole combination key released.Let us see another scenario:
Shift,InputEventKey: keycode=4194325 (Shift), mods=none, pressed=trueW,InputEventKey: keycode=87 (W), mods=shift, pressed=true, please notice there is mods=shiftW,InputEventKey: keycode=87 (W), mods=shift, pressed=false, please notice there is mods=shiftShift,InputEventKey: keycode=4194325 (Shift), mods=none, pressed=falseRelevant result of
is_input_pressed()is:As described above. The pressed condition is the same, the whole modifier have to cover the action. But the
shiftis 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.
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.