import pyautogui pyautogui.press('b')
You can try the pyautogui library, which has better compatibility.