How to detect CTRL + ALT key combinations in WPF

No.of Views7136
Bookmarked0 times
By  Prabu   On  03 Jul 2010 03:07:48
Tag : WPF , Miscellaneous
How to detect CTRL + ALT key combination in WPF
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at



The Key combination are a fancy pair of words to describe pressing/holding multiple keyboard buttons to perform a command.

Example :- Few of ever using key combination are,

  • Ctrl + S to Save,
  • Ctrl + C to Copy,
  • Alt + F4 to close an application,
  • Ctrl + Alt + Del to lock our computer, etc.

There are many such combination, and while I provided some common ones, many applications like Visual Studio provide their own key combination to help save you some time. Let's add some key combination to our little program also.


void SpecialKeyHandler(object sender, KeyEventArgs e)
    {// Ctrl + Nif ((Keyboard.Modifiers == ModifierKeys.Control) && (e.Key == Key.N))
        }// Ctrl + Oif ((Keyboard.Modifiers == ModifierKeys.Control) && (e.Key == Key.O))
        }// Ctrl + Sif ((Keyboard.Modifiers == ModifierKeys.Control) && (e.Key == Key.S))
        }// Ctrl + Alt + Iif ((Keyboard.Modifiers == (ModifierKeys.Alt | ModifierKeys.Control)) && (e.Key == Key.I))
            MessageBox.Show("Ctrl + Alt + I");

The key approach doesn't work for another reason because your commonly used Alt, Ctrl, Shift, and Windows keys can't be accessed from the Key enum at all. Instead, those four keys can only be accessed using the ModifierKeys enum and checking whether Keyboard.Modifiers is equal to that key.

That's all,now you able to handle key event in Windows Presentation application.thank you reading.

Sign Up to vote for this article
About Author
Occupation-Software Engineer
Member Type-Fresh
Joined date-23 Jun 2010
Home Page-
Blog Page-
Other popularSectionarticles
There is no comments for this articles.
Leave a Reply
Display Name:
(not display in page for the security purphase)
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top