Skip to content

ncmprbll/go-windows-keylogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Windows Keylogger written in Go

Simple keylogging library using Windows hooks.

Why?

I have found other Windows solutions to be ineffective and resource-demanding (especially regarding CPU) since they were using while loops, loops inside of while loops and some other forbidden wizardry.

Example

package main

import (
	"fmt"

	"github.com/ncmprbll/go-windows-keylogger"
)

func main() {
	listener, err := keylogger.NewListener()

	if err != nil {
		return
	}

	// vkCode == 112 is F1

	listener.Add(func(wParam uint64, vkCode uint64) {
		if wParam == keylogger.WM_KEYDOWN && vkCode == 112 {
			fmt.Println("F1 is being pressed or held down!")
		}
	})

	listener.Add(func(wParam uint64, vkCode uint64) {
		if wParam == keylogger.WM_KEYUP && vkCode == 112 {
			fmt.Println("Thank you for releasing the F1 button!")
		}
	})

	listener.Listen()
}

animated

Releases

No releases published

Packages

No packages published

Languages