• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

How do I capture the shift key when a mouse button is pressed?

When I left click a listbox, i want to capture the shift key state.  Can someone point me in the right direction?
1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
In the SelectedIndexChanged() event?...or the Click() event?...or the MouseDown() event?

Like this?

    Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left AndAlso My.Computer.Keyboard.ShiftKeyDown Then

        End If
    End Sub

Or maybe like this?

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If My.Computer.Keyboard.ShiftKeyDown Then

        End If
    End Sub

GCCalAuthor Commented:
Thanks for your help again.

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now