0
我想在控制檯中顯示我在Tk窗口中按下的內容。如何在Ruby Tk中綁定關鍵事件
我寫了下面的代碼:
require 'tk'
root = TkRoot.new
entry = TkEntry.new(root) do
pack
end
entry.bind("Key", proc {p "key pressed"})
Tk.mainloop
,如果我按任意鍵顯示key pressed
。
但我想顯示我按的鍵,而不是一個常量字符串。誰能幫我?