Create a Keylogger with Python – Tutorial



Learn how to create a keylogger for windows using Python. Get user keypresses and store them in a text file. This keyboard logging tutorial uses the pynput module.

Tutorial from Tech With Tim.
Check out Tim’s channel: https://www.youtube.com/channel/UC4JX40jDee_tINbkjycV4Sg

Learn to code for free and get a developer job: https://www.freecodecamp.org

Read hundreds of articles on programming: https://medium.freecodecamp.org

And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

source – For all your website needs, visit Spalding Web Design

45 comments

  1. im not to sure what i did wrong, i get the msg line 1, in <module>
    import pynput
    ModuleNotFoundError: No module named 'pynput' even tho ive installed pynput, please help me ill also really new so please no hate lmao

  2. the first step is to install pynput ?
    The assumption then is that you have Python already installed ….

    mmm

    Installed PYTHON38
    pip install pynput
    'pip' is not recognized as an internal or external command

    Thanks So much !
    Maybe the Tutorial should start back before you have Python or PIP installed ?

  3. Um excuse me my good sir, firstly super awesome tutorial, when you use the following code

    # with open("log.txt", "a") file:

    "a" in this case has two function it checks if the file exists or not. So in a way it creates the file for you and it starts appending values to it.

  4. hey !! nice video btw!! improved the keylogger but i am stuck at one point!! how to record the shift + some key character like ?,<,{,& etc . I have found to way to record this characters. Help needed . Thanks in advance!!

  5. Hey guys some help if you wouldnt mind, i cant get the write to file loop to start a new line every time i hit space, this is what i have thus far….
    def write_file(keys):

    with open("log.txt", "a") as f:

    for key in keys:

    k = str(key).replace("'"," ")

    if k.find("space") > 0:

    f.write('n')

    elif k.find("Key") == -1:

    f.write(k)

  6. i have Anaconda installed as well as PyCharm (I am using PyCharm). I installed pynput through the terminal as you have shown and yet ModuleNotFoundError: No module named 'pynput' still keeps appearing. Help? Thanks!

Leave a comment