import time
import pyautogui
pyautogui.keyDown('d')
time.sleep(x) # Insert time
pyautogui.keyUp('d)
This is a foolproof method of imitating "holding" down a key. I recommend making a function for this just because pyautogui is most likely not adding a time-based hold function.