{"id":18701302,"url":"https://github.com/marinx/keylogger","last_synced_at":"2025-04-05T08:09:47.503Z","repository":{"id":43701048,"uuid":"43242336","full_name":"MarinX/keylogger","owner":"MarinX","description":"Basic keylogger in Go (no C deps)","archived":false,"fork":false,"pushed_at":"2024-06-20T10:58:46.000Z","size":16,"stargazers_count":239,"open_issues_count":4,"forks_count":60,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T07:08:32.791Z","etag":null,"topics":["go","golang","keylogger","linux"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarinX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-27T10:17:49.000Z","updated_at":"2025-03-12T07:00:38.000Z","dependencies_parsed_at":"2024-11-07T11:55:17.971Z","dependency_job_id":null,"html_url":"https://github.com/MarinX/keylogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinX%2Fkeylogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinX%2Fkeylogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinX%2Fkeylogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarinX%2Fkeylogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarinX","download_url":"https://codeload.github.com/MarinX/keylogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","keylogger","linux"],"created_at":"2024-11-07T11:41:11.596Z","updated_at":"2025-04-05T08:09:47.482Z","avatar_url":"https://github.com/MarinX.png","language":"Go","readme":"# Keylogger\n\nCapture global keyboard events on Linux\n\n[![Build Status](https://travis-ci.org/MarinX/keylogger.svg?branch=master)](https://travis-ci.org/MarinX/keylogger)\n[![GoDoc](https://godoc.org/github.com/MarinX/keylogger?status.svg)](https://godoc.org/github.com/MarinX/keylogger)\n[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)\n\n## Notes\n* Only Linux based\n* Need root privilages\n\n## Installation\n```sh\ngo get github.com/MarinX/keylogger\n```\n\n## Getting started\n\n### Finding keyboard device\nThere is a helper on finding the keyboard.\n```go\n keyboard := keylogger.FindKeyboardDevice()\n```\nWhich goes through each file device name to find keyword \"keyboard\"\n```sh\n/sys/class/input/event[0-255]/device/name\n```\nand returns the file event path if found\n```sh\n/dev/input/event2\n```\nIf the function returns empty string, you will need to cat each device name and get the event number.\nIf you know already, you can easily pass it to constructor\n```sh\nkeylogger.New(\"/dev/input/event2\")\n```\n\n### Getting keypress\nOnce the keylogger returns channel event, you can switch by event code as described in [input_event.go](https://github.com/MarinX/keylogger/blob/master/input_event.go)\nFor start, you can listen on keyboard state change \n```go\nkeylogger.EvKey\n```\nOnce you get desire event, there is a helper to parse code into human readable key.\n```go\nevent.KeyString()\n```\n\n### Writing keypress\nBest way is to open an text editor and see how keyboard will react\nThere are 2 methods:\n```go\nfunc (k *KeyLogger) WriteOnce(key string) error\n```\nand\n```go\nfunc (k *KeyLogger) Write(direction KeyEvent, key string) error \n```\n`WriteOnce` method simulates single key press, eg: press and release letter M\n\n`Write` writes to keyboard and sync the event. \nThis will keep the key pressed or released until you call another write with other direction\neg, if the key is \"A\" and direction is press, on UI, you will see \"AAAAA...\" until you stop with release\n\nProbably you want to use `WriteOnce` method\n\n**NOTE**\n\nIf you listen on keyboard state change, it will return __double__ results.\nThis is because pressing and releasing the key are 2 different state change.\nThere is a helper function which you can call to see which type of state change happend\n```go\n// returns true if key on keyboard is pressed\nevent.KeyPress()\n\n// returns true if key on keyboard is released\nevent.KeyRelease()\n```\n\n### Example\nYou can find a example script in ```example/main.go```\n\n### Running tests\nNo magic, just run\n```sh\ngo test -v\n```\n\n## Creating key sniffer (needs update)\n* [sniffing global keyboard events in go](https://medium.com/@marin.basic02/sniffing-global-keyboard-events-in-go-e5497e618192/)\n\n\n## License\nThis library is under the MIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarinx%2Fkeylogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarinx%2Fkeylogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarinx%2Fkeylogger/lists"}