Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleTell whether the Shift key is pressed during a mouse click in Visual Basic .NET
DescriptionThis example shows how to tell whether the Shift key is pressed during a mouse click in Visual Basic .NET.
Keywordsmouse, MouseClick, Shift, click, mouse click, VB.NET
CategoriesTips and Tricks, Miscellany
 
Use My.Computer.Keyboard.ShiftKeyDown to see if the Shift key is down. (Note: This example was written in VB 2005.)
 
Public Class Form1
    Private Sub Form1_MouseClick(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.MouseEventArgs) _
        Handles Me.MouseClick
        If My.Computer.Keyboard.ShiftKeyDown Then
            Me.Text = "Shift+Click"
        Else
            Me.Text = "Click"
        End If
    End Sub

    Private Sub Form1_MouseDoubleClick(ByVal sender As _
        Object, ByVal e As _
        System.Windows.Forms.MouseEventArgs) Handles _
        Me.MouseDoubleClick
        If My.Computer.Keyboard.ShiftKeyDown Then
            Me.Text = "Shift+DoubleClick"
        Else
            Me.Text = "DoubleClick"
        End If
    End Sub
End Class
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated