我想查看键盘事件,根据文档,Sensor
我可以做到这一点,而无需从队列中删除事件peekKeyboardEvent
,但它似乎不起作用。
这有效:
"Show that a single event can be checked multiple times"
Transcript clear; show: 'Type something... '; flush.
(Delay forSeconds: 2) wait.
5 timesRepeat: [
Transcript show: (Sensor peekEvent); cr
]
输出:
Type something... #(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
但这不会:
"Show that a single keyboard event can be checked multiple times"
Transcript clear; show: 'Type something... '; flush.
(Delay forSeconds: 2) wait.
5 timesRepeat: [
Transcript show: (Sensor peekKeyboardEvent); cr
]
输出:
Type something... #(2 48205144 97 0 0 97 0 1)
nil
nil
nil
nil
另一个问题:为什么不Transcript flush
导致输出立即出现?它仅在脚本运行后出现。