Detecting if Shift button pressed

kejpa

Junior Contributor
Joined
Oct 10, 2003
Messages
320
Hi,
How can I detect if the Shift button is pressed when handling a button click event?

Is it stated somewhere in the EventArgs parameter or do I have to have a form variable that contains which buttons (Shift/Ctrl/Alt) that currently are pressed?

TIA
/Kejpa
 
Use the static property ModifierKeys of the Control class:
Code:
private void button1_Click(object sender, EventArgs e)
{
    if (Control.ModifierKeys == Keys.Shift)
    {
        MessageBox.Show("Shift Pressed");
    }
}
 
Back
Top