Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - How to capture when CTRL+SHIFT are pressed down?

When the user clicks left CTRL+ left SHIFT I want to make the entire application translucent (like VS2008's intellisense drop-down). If I write my code on the KeyUp event I can capture both keys being pressed, but the transparency effect should only be active while the keys are pressed. When they are release the opacity should go back to 100%. The behavior I want is actually the KeyDown event, but I can't capture both keys on KeyDown, can I?

Thanks

like image 237
Gus Cavalcanti Avatar asked Dec 03 '22 15:12

Gus Cavalcanti


1 Answers

Use the static methods of the Keyboard class, specifically IsKeyDown() to check the state of the keys you're interested in.

On KeyDown you can use this to enable the translucency and on KeyUp you can disable the effect again. If you are at it, you could save the key's state yourself and act upon it.

like image 162
David Schmitt Avatar answered Jan 05 '23 08:01

David Schmitt