Paul Williams
Paul Williams

Reputation: 1598

An event handle for holding SHIFT during a button click on a Winforms

I have the following event handle in my Visual Basic.NET project form (VS 2013).

I wanted to know if I can modify it so that I can distinguish between a normal click and when someone is holding either SHIFT button during the button press.

Private Sub btnLLDoubleDip_Click(sender As Object, e As EventArgs) Handles btnLLDoubleDip.Click
    ' Double Dip is easy...

    ' Stop the timer

    ' Create a flag that this is now a double dip attempt, NO MORE WALK OUTS
End Sub

Upvotes: 4

Views: 1987

Answers (1)

LarsTech
LarsTech

Reputation: 81620

You can use the ModifierKeys.HasFlag function for that:

If ModifierKeys.HasFlag(Keys.Shift) Then
  MessageBox.Show("Shift is pressed")
Else
  MessageBox.Show("Shift is not pressed")
End If

Upvotes: 7

Related Questions