Creating Shortcut Keys

bigklaxer

Member
Joined
Jul 2, 2009
Messages
6
Programming Experience
1-3
So I've been trying to make a form in which a few of the buttons have keyboard shortcuts such as the F keys as well as the arrow buttons. Here's the code I've been using

Private Sub frmOrganizer_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If obSelect = True Then
If e.KeyCode = Keys.F3 Then
If shortcut1 = False Then
shortcut1 = MakeShortcut(btnSC1)
Else
CategorizeFile(btnSC1.Text.Substring(0, btnSC1.Text.IndexOf(ControlChars.Quote) - 1))
End If
End If
Else : MessageBox.Show("Please select a category first.")
End If

It seems to me like this should work but it doesn't when I run the program. I think it might possibly be something with buttons being selected on the form. If this is so how would I go about fixing it?
 
Have you set the form's KeyPreview property to True? If not it won't raise any KeyDown, KeyUp or KeyPress events when a control that processes keyboard input itself has focus.
 
Back
Top