When my application starts up in the static void Main method I want to determine if a key like Alt or Ctrl is pressed and then start the Application in some kind of Option-Mode. How can I find out if a key is pressed during startup?
I found some samples already but they all import a windows dll, something I don't want to do.
Use Keyboard.IsKeyDown() static method will help you to check the state of the keys you're interested in.
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)
|| Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt) )
{
//Load in a special mode
}
else
{
//Load standard mode
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With