基本です。.bindでkeyが打たれたときの状態を感知することができます。 import tkinter as tk root = tk.Tk() def key_event(e): print(e.keysym) root.bind("<KeyPress>", key_event) root.mainloop() このコードを実行してキーボードを叩けばprint関数で打ったkeyが出力されます。
Continuing the exploration of using Tkinter with Python, this version adds catching 'Tab' or 'Return' keypress within the 'Entry' widget.
DO NOT use this script on other systems without their permission. Only use it on your own system and for educational purposes. You might want to change to an exe by ...
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する