Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
good day guys. i want to know how will you find out if the ctrl + alt is press? any code for it?
Posted
Updated 1-Apr-11 18:34pm
v2

KeyEventArgs has 2 booleans for that - Alt and Control.

Use KeyDown event to check for that.
 
Share this answer
 
v2
Comments
Madzmar25 29-Mar-11 0:41am    
how?
Prerak Patel 29-Mar-11 6:10am    
Need more description from your side to answer your HOW
C#
private void Form1_KeyDown(object sender, KeyEventArgs e)
       {

               if (e.Alt || e.Control)
               {
                // do somethings
               }

       }
 
Share this answer
 
C#
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.Alt)
    {
        MessageBox.Show("Ctrl + Alt pressed");
    }
}
 
Share this answer
 
Comments
Madzmar25 29-Mar-11 0:56am    
i guess it only works when you have the textbox in focus right? i tried applying it on globalhook and i place it on delete key to check if the ctrl + alt is pressed but i failed i cant get it to check if the ctrl+alt is pressed
You can also have a look at this article that lets you detect if these keys are pressed even if your application is not in focus:
Processing Global Mouse and Keyboard Hooks in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900