I would suggest that you do this the way VS does. In your UI, give the user a list of possible keys to choose from and then use CheckBoxes to select Ctrl, Shift and Alt. You can then store four values: Booleans for Ctrl, Shift and Alt and a String for the key. Your test will then look like this:
vb.net Code:
If e.KeyCode = DirectCast([Enum].Parse(GetType(Keys), key), Keys) AndAlso _
e.Control = ctrl AndAlso _
e.Shift = shift AndAlso _
e.Alt = alt Then
'The hotkey was detected.
End If
An even better idea would be to create a composite Keys value when the user makes there selection and store that:
vb.net Code:
Dim hotkey As Keys = DirectCast([Enum].Parse(GetType(Keys), Me.keyComboBox.Text), Keys)
If Me.ctrlCheckBox.Checked Then
hotkey = hotkey Or Keys.Control
End If
If Me.shiftCheckBox.Checked Then
hotkey = hotkey Or Keys.Shift
End If
If Me.altCheckBox.Checked Then
hotkey = hotkey Or Keys.Alt
End If
You can then compare that value to e.KeyData in your KeyDown event handler.
A better idea still would be to populate your ComboBox with Keys values in the first place. If you put enumerated constants in a ComboBox then it will display their text labels, but the SelectedItem will still be a Keys value, so there's no need to parse a string: