Eng:Key () Pressed? (block)

The Key Pressed? block is a Sensing block and a Boolean block. The block checks if the specified key is pressed. If the key is being pressed, the block returns "true"; if it is not, it returns "false".

The keys available to be used in this block include the entire English alphabet ( a b c etc.), the number keys ( 0 1 2 etc.), the arrow keys ( left up right down ), and the space key. In the Experimental Viewer, the enter key could also be chosen. After an update, this block now includes an any option, which allows one to press any key to operate the block.

Example Uses
As this block checks if a key is being pressed or not, it is useful for controlling objects, especially with One Sprite One Script Projects. If the project requires key input, this block can be used to serve as a replacement for the When Key Pressed block. The Hat block cannot be used in the middle of a script.

Some common uses for the Key Pressed? block: forever if  then change y by (-10) end if  then change y by (10) end if  then change x by (-10) end if  then change x by (10) end say [Hello!] wait until  wait until > say [Welcome to my game!]
 * Controlling a character
 * Word processors
 * Moving objects
 * Changing slides in slideshows or changing what characters say

Sensing Scrolling
The When Key Pressed block, the counterpart to the Key  Pressed? block, senses the scroll wheel as well as the up/down keys. Combining these two blocks, it is possible to sense when somebody is using the scroll wheel. The following script is one way of doing this. when key [up arrow v] pressed if > then . . . The action is done when the scroll wheel is scrolled up. If the key pressed blocks are changed to the down arrow, it will sense when it is scrolled down.

Suggestions
There are four somewhat popular suggestions related to this block:
 * Add more keys
 * Make a reporter block that says what key is being pressed
 * Allow drop-ins in the drop-down menu like in the costume drop-down menu (see Enabling Dropping for instructions on how to do this yourself by modifying the Squeak code)
 * Make this a Stage Monitor

Some Scratch Modifications have at least one of these.