Made with Kleap
MouseLag Sim Get started
Python Β· pynput

Simulate mouse lag,
on purpose.

A tiny Python script that programmatically moves your cursor with random jitter and delay β€” useful for testing input handling, screencasts, or just experimenting with automation.

10
lag iterations
Β±5px
random jitter
0.1–0.5s
delay range
100%
programmatic

The script

The full source, in 25 lines.

Drop it in a .py file and run it. Press Ctrl+C to stop.

mouse_lag.py Python 3
import time
import random
from pynput.mouse import Controller, Listener

mouse = Controller()

def simulate_lag():
    for _ in range(10):  # Simulating lag 10 times
        mouse.move(random.randint(-5, 5), random.randint(-5, 5))
        time.sleep(random.uniform(0.1, 0.5))  # Random delays to simulate lag

def simulate_zoom():
    print('Zooming in...')
    # In a real implementation, here you'd add code to zoom in on the screen

if __name__ == '__main__':
    print('Press Ctrl+C to stop the simulation')
    try:
        simulate_lag()
        simulate_zoom()
    except KeyboardInterrupt:
        print('Stopped by user')

How it works

Three pieces, working together.

01

Take control of the mouse

A Controller instance from pynput.mouse gives you programmatic access to the cursor β€” same input layer as a real user.

02

Inject random jitter

Each loop iteration nudges the cursor by a random pixel offset between βˆ’5 and +5 on both axes.

03

Sleep with random delay

A 0.1–0.5 second pause between moves creates an organic, laggy rhythm β€” not a clean loop.

Install

One dependency.
One command.

Install pynput with pip, then run the script. macOS users may need to grant Accessibility permissions to your terminal app.

$ pip install pynput
$ python mouse_lag.py
Press Ctrl+C to stop the simulation

Ready to lag some mice?

Copy the script, install pynput, and watch your cursor dance.

Copy the script