c# - Multiple keys with WPF KeyDown event -


i'm working wpf keydown event (keyeventargs windows.input). need recognize when user pressed f1 alone , ctrl+f1.

   private void window_keydown(object sender, keyeventargs e)     {         if (e.key==key.f1 && keyboard.iskeydown(key.leftctrl))         {             messagebox.show("ctrlf1");         }         if (e.key == key.f1 && !keyboard.iskeydown(key.leftctrl))         {             messagebox.show("f1");         }     } 

my problem when press ctrl+f1 plain f1 messagebox fire too. tried add e.handled ctrl+f1 case, doesn't help.

use:

else if..... 

in case both options fired, because press f1 key in both cases.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -