Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim FoundKeys As String
On Error Resume Next
Dim AddKey
KeyResult = GetAsyncKeyState(13)
If KeyResult = -32767 Then
AddKey = vbCrLf
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(8)
If KeyResult = -32767 Then
l = Len(Text1.Text)
AddKey = "[Backspace]"
GoTo KeyFound
End If
'------------FUNCTION KEYS
'------------SPECIAL KEYS
KeyResult = GetAsyncKeyState(32)
If KeyResult = -32767 Then
AddKey = " "
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(186)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "è" Else AddKey = "é"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(187)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "+" Else AddKey = "*"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(188)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "," Else AddKey = ";"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(189)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "-" Else AddKey = "_"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(190)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "." Else AddKey = ":"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(191)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "ù" Else AddKey = "§" '/
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(192)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "ò" Else AddKey = "ç" '`
GoTo KeyFound
End If
'----------NUM PAD
KeyResult = GetAsyncKeyState(96)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "0" Else AddKey = "="
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(97)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "1" Else AddKey = "!"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(98)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "2" Else AddKey = Chr(34)
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(99)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "3" Else AddKey = "£"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(100)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "4" Else AddKey = "$"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(101)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "5" Else AddKey = "%"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(102)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "6" Else AddKey = "&"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(103)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "7" Else AddKey = "/"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(104)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "8" Else AddKey = "("
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(105)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "9" Else AddKey = ")"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(106)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "'*" Else AddKey = ""
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(107)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "+" Else AddKey = "+"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(108)
If KeyResult = -32767 Then
AddKey = ""
If GetShift = False Then Text1.Text = Text1.Text & vbCrLf
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(109)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "-" Else AddKey = "_"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(110)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "." Else AddKey = ""
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(2)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "/" Else AddKey = "/"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(220)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "\" Else AddKey = "|"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(222)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "à" Else AddKey = °
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(221)
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "ì" Else AddKey = "^"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(219) '219
If KeyResult = -32767 Then
If GetShift = False Then AddKey = "[" Else AddKey = "{"
GoTo KeyFound
End If
For n = 65 To 128
KeyResult = GetAsyncKeyState(n)
If KeyResult = -32767 Then
If GetShift = False Then
If GetCapslock = True Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
Else
If GetCapslock = False Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
End If
GoTo KeyFound
End If
Next n
For n = 48 To 57
KeyResult = GetAsyncKeyState(n)
If KeyResult = -32767 Then
If GetShift = True Then
Select Case Val(Chr(n))
Case 1
AddKey = "!"
Case 2
AddKey = Chr(34)
Case 3
AddKey = "£"
Case 4
AddKey = "$"
Case 5
AddKey = "%"
Case 6
AddKey = "&"
Case 7
AddKey = "/"
Case 8
AddKey = "("
Case 9
AddKey = ")"
Case 0
AddKey = "="
End Select
Else
AddKey = Chr(n)
End If
GoTo KeyFound
End If
Next n
DoEvents
Exit Sub
KeyFound:
If AddKey = "A" Then
'ESEGUI L'AZIONE DI PAUSA
End If
DoEvents
End Sub