|当 () 键被按下|
The keys that can be sensed with this block include the entire English alphabet (etc.), the number keys ( etc.), the arrow keys ( ), and the key. After an update, this block now includes an option, which allows one to press any key to operate the block.
In the 实验查看器, the key (or key on Macs) could also be sensed.
The block will act similarly to typing text in a text box. There will be a delay between when the block first executes and the second time, but after that, there will be no delay until the key is released.
This block is used to get input from the player, for a variety of uses.
Some common uses include:
- Controlling an object
當 [空白 v] 鍵被按下 廣播訊息 [Fire! v] 重複 (5) 次 y 改變 (5) end
- Typing on a word processor
當 [a v] 鍵被按下 造型換成 [a v] 蓋章 x 改變 (20)
- Starting 动画类专案
當 [空白 v] 鍵被按下 廣播訊息 [Animation starts! v] 播放音效 [Intro v]
- Moving around a map
當 [向上 v] 鍵被按下 y 改變 (15)
|Note:||Because of the built in delay, the |
- Main article: List of Block Workarounds
This block can be partially replicated with the following code:
當 @greenflag 被點擊 重複無限次 如果 <[某 v] 鍵被按下？> 那麼 . . . end end
|Note:||This workaround is not exact, as the hat block will break off in the middle of a 程式, but the workaround will not. The built-in delay in the hat block (if you hold down the key, there will be a slight pause, followed by a shorter pause) is not inherent in the workaround. Also, the hat block does not require the green flag to be pressed.|
A more precise workaround:
when gf clicked 重複無限次 如果 <[某 v] 鍵被按下？> 那麼 廣播訊息 [ready v] end end
當收到訊息 [ready v] . . .