[KBM] Fixed Ctrl key state handling during and after shortcuts invoked by AltGr#31923
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jaimecbernardo
left a comment
There was a problem hiding this comment.
I've given it a test and ran into a weird bug where it seems Ctrl(Left) got stuck.
I did the following mapping, as per the example:

After that I wrote a bunch of stuff on notepad++. and tried the mapping:
1 - Press AltGr key.
2 - Press Backspace key.
3 - Release Backspace key.
4 - Press left arrow key.
5 - Release left arrow key.
6 - Release Alt Gr.
The left Ctrl key got stuck even though I'm not pressing anything. PTAL.
This reverts commit 2774e1c.
| isAltRightKeyInvoked = true; | ||
|
|
||
| // Check if the left control is pressed when right Alt key (AltGr) is pressed. If it is release it. | ||
| if ((data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP) && ii.GetVirtualKeyState(VK_LCONTROL)) |
There was a problem hiding this comment.
why is this needed? This is not good behavior. If I hold down Left Ctrl and then press and release Right Alt, Left Ctrl is being released even though I'm still holding it down.
| // Check if the right Alt key (AltGr) is pressed. | ||
| if (data->lParam->vkCode == VK_RMENU) | ||
| { | ||
| isAltRightKeyInvoked = true; |
There was a problem hiding this comment.
this can be both KEYUP or KEYDOWN. Should isAltRightKeyInvoked be set to true on KEYUP?
|
|
||
| // Prevents the unintended release of the Ctrl part when AltGr is pressed. AltGr acts as both Ctrl and Alt being pressed. | ||
| // After triggering a shortcut involving AltGr, the system might attempt to release the Ctrl part. This code ensures Ctrl remains pressed, maintaining the AltGr state correctly. | ||
| if (isAltRightKeyInvoked && data->lParam->vkCode == VK_LCONTROL && it->first.GetActionKey() != VK_LCONTROL && (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)) |
There was a problem hiding this comment.
it->first.GetActionKey() != VK_LCONTROL action key can't be VK_LCONTROL if I'm not wrong?
| bool isMatchOnChordEnd = false; | ||
| bool isMatchOnChordStart = false; | ||
|
|
||
| static bool isAltRightKeyInvoked = false; |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
stefansjfw
left a comment
There was a problem hiding this comment.
Tested different altgr and ctrl combinations. Looks good
Summary of the Pull Request
Shortcuts involving the AltGr key does not behave as expected. The problem is that when AltGr(ctrl + alt) + Action Key is pressed, the ctrl release event immediately follows.
Also, in some cases, when the AltGr key is released, it behaves as if the ctrl key is still pressed.
PR Checklist
Detailed Description of the Pull Request / Additional comments
After pressing the Ctrl + AltGr + Action keys, it was observed that the Ctrl release event did not occur. In AltGr + Action key, the Ctrl release event comes first. To prevent this, a control was created with the "isAltRightKeyInvoked" boolean variable. The first Ctrl release event is skipped.
During the tests, it was seen that Ctrl was still pressed while AltGr was released. Added a check to prevent this. Example test case:
ctrl left + alt right + b -> ctrl left --- alt gr + b + a to select all then release all keys and try to press a key.
Validation Steps Performed