
 نوشته شده توسط 
mazoolagh
					
				 
				3- قطعا key preview رو روشن کردین.
4- اگر در فرم textbox یا هر کنترلی که قابلیت key-press داره داشته باشین که قرار هست text هم قبول کنه، باید یک فکری براش بکنین.
			
		 
	 
 سلام بالاخره نوشتم 
Friend Class DoubleKeyPressHandler    Private keyQueue As New Queue(Of Keys)
    Public Sub New()
        Actions = New Dictionary(Of Integer, Action) From {
            {Keys.D2 << 16 Or Keys.D5, Sub() Call New Form2().Show()},
            {Keys.NumPad2 << 16 Or Keys.NumPad5, Sub() Call New Form2().Show()},
            {Keys.NumPad2 << 16 Or Keys.A, Sub() Call New Form3().Show()},
            {Keys.D2 << 16 Or Keys.A, Sub() Call New Form3().Show()}
        }
    End Sub
    Public ReadOnly Actions As Dictionary(Of Integer, Action)
    Public Sub Add(ByVal key As Keys)
        keyQueue.Enqueue(key)
        TryMapKeys()
    End Sub
    Private Sub TryMapKeys()
        If keyQueue.Count < 2 Then Return
        Dim key1 = keyQueue.Dequeue
        Dim key2 = keyQueue.Dequeue
        Dim dKey = key1 << 16 Or key2
        Dim keyAction As Action = Nothing
        If Actions.TryGetValue(dKey, keyAction) Then
            keyAction.Invoke()
        Else
            ' If the combination is not a match, the last Key is added back
            ' Remove the Else block if you prefer to cancel it instead. Test it.
            keyQueue.Enqueue(key2)
        End If
    End Sub
End Class