This project provides both a command-line interface (CLI) and a graphical user interface (GUI) for recording keyboard events and exporting them to CSV files. It only works when run as a superuser and relies on the keyboard library.
- Record keyboard events and save them as CSV files.
- Command-line interface for quick usage.
- Graphical user interface for interactive usage.
- Filter which key events to record (key up, key down, or both).
To install the project and its dependencies, you need to have Poetry installed. Once you have Poetry set up, you can install the project by running:
poetry installTo start recording keyboard events and save them as a CSV file:
sudo -E poetry run keylogger --output /path/to/output_directoryExample:
sudo -E poetry run keylogger --output ./logsYou can also filter which events to record:
-
Only key up events:
sudo -E poetry run keylogger --output ./tests --U
-
Only key down events:
sudo -E poetry run keylogger --output ./tests --D
-
Both key up and key down events (default, or specify both):
sudo -E poetry run keylogger --output ./tests --U --D
-
The keylogger will start immediately and save logs in the specified directory.
-
Press
Ctrl+Cto stop recording while the terminal is focused.
To use the graphical interface:
sudo ./dist/keylogger/keylogger-gui- Select the output directory and use the Start/Stop buttons to control logging.
Note: The
keyboardlibrary requires root privileges on Linux. Always usesudowhen running the CLI or GUI.
You can bundle both the CLI and GUI as standalone executables for Linux or Windows using PyInstaller.
First, install the development dependencies:
poetry install --with devThen, to build both executables:
On Linux:
poetry run pyinstaller keylogger.specOn Windows:
poetry run pyinstaller keylogger.specThe standalone executables will be created in the dist/keylogger/ directory:
keylogger.exe(CLI)keylogger-gui.exe(GUI)
Note:
- You must run PyInstaller on the target OS (build on Linux for Linux, on Windows for Windows).
- For advanced options, see the PyInstaller documentation.
This project is licensed under the Apache-2.0 License. See the LICENSE file for more details.