[VB2008]

03/04/2010 14:37 maxxx69de#1
Sorry that "no" Topic was given : Topic should be : Get Keypress with Modifier
(Perhaps mod can change, thanks)

Hello all,

I have a "Text Box" in which a user has to enter a HotKey for a special action in game.

The Hotkey can be any combination from (one)number, (one)letters with or without Shift or Ctrl or Alt.

My problem is to get what was entered if a modifier key is presst.

e.g. :

User enters "!" and I want to display "SHIFT + 1" in the textbox
same with ALT or CTRL

I have this code to get the modifier:

Code:
Private Sub txtHPTKey_Keydown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHPTKey.KeyDown


        If (Control.ModifierKeys And Keys.Shift) = Keys.Shift Then txtHPTKey.Text = "SHIFT + "
        If (Control.ModifierKeys And Keys.Control) = Keys.Control Then txtHPTKey.Text = "CTRL + "
        If (Control.ModifierKeys And Keys.Alt) = Keys.Alt Then txtHPTKey.Text = "ALT +"


    End Sub
Can anybody please help how I can solve "my problem" ?

Thanks.

Maxxx.

* SOLVED * :

Code:
 Private Sub txtHPTKey_Keyup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtHPTKey.KeyUp

        If (Control.ModifierKeys And Keys.Shift) = Keys.Shift Then txtHPTKey.Text = "SHIFT + " & Convert.ToChar(e.KeyCode)
        If (Control.ModifierKeys And Keys.Control) = Keys.Control Then txtHPTKey.Text = "CTRL + " & Convert.ToChar(e.KeyCode)
        If (Control.ModifierKeys And Keys.Alt) = Keys.Alt Then txtHPTKey.Text = "ALT + " & Convert.ToChar(e.KeyCode)
        e.Handled = True