import mouse import keyboard import time mouse_events = [] mouse.hook(mouse_events.append) keyboard.start_recording() keyboard.wait("f") mouse.unhook(mouse