Building a Python Keylogger: A Security Researcher’s development to Understanding Keystroke Logging
Setting up USB Autorun (for testing): Windows: You would need an autorun.inf file on the USB, but keep in mind this is typically disabled by default for security.
Linux/macOS: You can set up a udev rule on Linux that triggers a script when a USB drive is inserted.
Here’s an example of how you might trigger your Python script on Linux when a USB drive is inserted using udev rules.