import mouse
import time
from pynput.keyboard import Controller

keyboard = Controller()

def click(button, speed: float = 1, duration: float = 10, delay: float = 0):
    time.sleep(delay)
    clicks = int(duration/speed)
    if button == 'left' or button == 'right' or button == 'middle':
        for i in range(0, clicks):
            mouse.click(button)
            time.sleep(speed)
    else:
        for i in range(0, clicks):
            keyboard.press(button)
            keyboard.release(button)
            time.sleep(speed)