https://item.taobao.com/item.htm?from=cart&id=771194972569&pisk=f8nsFbjz51fs1GLwPtpUPW36bmrjcjtyctwxExINHlETGoMjerI2SlzbcXFEb5kaXSZjhYUxgSkNI2creGowSoSbjoqvaQ-y4ODgmoFaQ0_Nske7enSAX-KXde_DaQ-ycFBLcCOr_GiSnMe7eoeTk5Cpd-yVDshADkpQH-5OkGhvdvF3h1QAXrILp-yzBoIOXkELQ8BO6reOJHF3HoeYkjjRF-T_sA9nneu-B9atBWsSKDwtNND_OL9-A2Z3w0PCDinQCvVE4WIWu73u_zP-9HS_cvejOzu6NGGjHY0YRm19QbhKljen-I_bNqHZrDzFHNHIc5a-Xy6DUYHgHjUj-QszCluQPcgMn6Hta5g8jxWW_vaSRz2LJt_Tb4krmzn9f_VUr-GQzVO5fbIr9gPS_S_fdzjbd7JBdZbmcpBhVOe7qqUTKRaedp1toPe3df9BdaG3WJ2esp9Cr45..&skuId=5282271208260&spm=a1z0d.6639537%2F202410.item.d771194972569.7e5c74840sIplV
from pynput import keyboard # 特殊按键 keyboard.Key.down keyboard.Key.up keyboard.Key.left keyboard.Key.right # 普通按键 def on_press(key): try: print(f"{key.char} 被按下") except AttributeError: print(f"特殊键 {key} 被按下") # def on_release(key): print(f"{key} 被释放") if key == keyboard.Key.esc: return False with keyboard.Listener(on_press=on_press, on_release=on_release) as listener: listener.join()