Skip to content

A clean and educational Python keystroke logger with smart auto-save functionality and readable output formatting. Features inactivity-based buffering, filtered special keys, and organized session tracking. Designed for educational purposes and personal productivity tracking.

Notifications You must be signed in to change notification settings

gatiella/python_keylogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Enhanced Keyboard Logger

A clean, educational Python keyboard logger with improved formatting and readability.

🎯 Features

  • Clean Output Format: No clutter from modifier keys (Ctrl, Shift, Alt) or navigation keys
  • Smart Auto-Save: Automatically saves typed content after 3 seconds of inactivity
  • Readable Logs: Timestamped entries with clear separators
  • Session Tracking: Records session start/end times and duration
  • Graceful Exit: Press ESC to stop logging safely

📋 Requirements

pip install keyboard

Note: On Windows, the script may require administrator privileges. On Linux, you may need to run with sudo.

🚀 Usage

  1. Basic Usage:

    python keylogger.py
  2. The logger will:

    • Create a keystroke_log.txt file
    • Display the log file location
    • Start capturing keystrokes
    • Auto-save after 3 seconds of typing inactivity
  3. To stop: Press the ESC key

⚙️ Customization

You can customize the logger settings in the main() function:

logger = KeyboardLogger(
    log_file="my_custom_log.txt",  # Custom log file name
    buffer_time=5                   # Save after 5 seconds of inactivity
)

📝 Log Format

The output is clean and organized:

KEYSTROKE LOG - CLEAN FORMAT
======================================================================
Session Started: 2025-10-09 08:00:00 AM
======================================================================

[2025-10-09 08:00:15 AM]
This is a sample of typed text that appears cleanly in the log.
----------------------------------------------------------------------

[2025-10-09 08:00:45 AM]
Another batch of text after a pause in typing.
----------------------------------------------------------------------

======================================================================
SESSION SUMMARY
======================================================================
Started:  2025-10-09 08:00:00 AM
Ended:    2025-10-09 08:05:30 AM
Duration: 0:05:30
======================================================================

🔍 What Gets Logged

  • ✅ Regular alphanumeric keys
  • ✅ Space, Enter, Tab
  • ✅ Backspace (removes last character)
  • ❌ Modifier keys (Ctrl, Alt, Shift, Win/Cmd)
  • ❌ Navigation keys (arrows, Page Up/Down, Home/End)
  • ❌ Function keys (F1-F12)

⚠️ Important Notes

Legal & Ethical Use

  • Educational purposes only: This tool is for learning about keystroke logging
  • Personal use only: Only use on your own computer
  • Privacy: Never use this to monitor others without explicit consent
  • Legal compliance: Unauthorized keystroke logging is illegal in most jurisdictions

Technical Considerations

  • Requires appropriate system permissions
  • May be flagged by antivirus software (false positive for legitimate educational tools)
  • Should not be used on shared or public computers

🛡️ Privacy & Security

This is a basic educational implementation. If you're concerned about keystroke logging on your system:

  • Keep your OS and security software updated
  • Be cautious about running unknown scripts
  • Use reputable security software
  • Review running processes regularly

📜 License

For educational purposes only. Use responsibly and ethically.

🤝 Contributing

This is an educational project. Feel free to learn from the code and adapt it for your own learning purposes.


Disclaimer: The authors are not responsible for misuse of this tool. Always respect privacy laws and ethical guidelines.

About

A clean and educational Python keystroke logger with smart auto-save functionality and readable output formatting. Features inactivity-based buffering, filtered special keys, and organized session tracking. Designed for educational purposes and personal productivity tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages