DIR Return Create A Forum - Home
---------------------------------------------------------
Hack Community
HTML https://roshacks.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: VB.NET
*****************************************************
#Post#: 523--------------------------------------------------
[VB.NET] CheckKeyPress
By: pipo1337 Date: May 13, 2018, 2:58 pm
---------------------------------------------------------
CheckKeyPress.vb
[code]Imports System.Runtime.InteropServices
Public Enum KeyState As Integer
None = 0
Press = 1
Release = 2
End Enum
Public Class CheckKeyPress
'Private isPressed As Boolean
Private registeredKey As New Dictionary(Of Keys, Boolean)
Public Function getKeyPress(ByVal key As Keys) As KeyState
If Not registeredKey.ContainsKey(key) Then
registeredKey.Add(key, False)
End If
If (API.GetAsyncKeyState(key) <> 0) Then
If Not registeredKey(key) Then
registeredKey(key) = True
'Console.WriteLine("Pressed")
Return KeyState.Press
End If
ElseIf registeredKey(key) Then
'Console.WriteLine("Release")
registeredKey(key) = False
Return KeyState.Release
End If
Return KeyState.None
End Function
End Class
[/code]
*****************************************************