sanketkheni01 / Windows-11-Virtual-desktop-animation

MIT License
118 stars 10 forks source link

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

Open deltaidea opened 1 year ago

deltaidea commented 1 year ago

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:

https://github.com/sanketkheni01/Windows-11-Virtual-desktop-animation/blob/dc7e1db0ef2406e197773ce8bf857d87e41e6e55/Exelus.Win11DesktopSwitchAnimatior/Exelus.Win11DesktopSwitchAnimatior/Program.cs#L45-L49

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 1 year ago

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