Continuing the exploration of using Tkinter with Python, this version adds catching 'Tab' or 'Return' keypress within the 'Entry' widget.
基本です。.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が出力されます。
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する