sanketkheni01/Windows-11-Virtual-desktop-animation

Default behavior of "Ctrl + Up/Down" is not being prevented

deltaidea opened this issue · 1 comments

Hi! Thanks for making this utility!

I ran into the following issue.

Expectations

You should see either key code 17 (ControlLeft) or 91 (OSLeft) shown on the page when you return to the left desktop. Notably, you will not see key code 39 (ArrowRight) because Windows does not let the keyboard event pass to applications if it triggers a Windows hotkey.

I expect pressing Ctrl + Win + Down to have the same outcome. In other words, I expect the last key that I press in the combo to not result in a "key down" for other apps. I am not sure if the "key up" event should be propagated though - I didn't test this - but it should mirror the default behavior exactly, including if I release the keys in a different order compared to how I pressed them down.

Actual behavior

When you return to the left desktop, you will see key code 40 (ArrowDown), which means the browser has received all three key presses. In other words, any active application will act as if I pressed Ctrl+Down (if it doesn't check Win). This causes unwanted side-effects for me.

Environment

Other notes

It looks like you're currently passively checking if the relevant keys are pressed:

var ctrlState = GetAsyncKeyState(17);
var winState = GetAsyncKeyState(91);
var upArrowState = GetAsyncKeyState(38);
var downArrowState = GetAsyncKeyState(40);
var altKeyState = GetAsyncKeyState(18);

I'm not sure if it's possible to prevent other apps from getting key events with this approach. We might have to use WndProc or maybe call some sort of low-level Windows DLL.

Thanks again! 💚

NNois commented

Well, using up down is not correct it remove a useful windows feature I agree why not sticking with the default keys (left right) ?