Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    When Key Pressed/Released Blocks

    2D Blocks
    1
    1
    804
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

       

      Prerequisite

      • Working with Sprites

       

      Description

      The “When () Key Pressed” and “When () Key Released” blocks are Hat Blocks in the Events category.


       

      The When () Key Pressed Block

      This block plays the blocks attached below it when the selected key is pressed down on the keyboard.


       

      The When () Key Released Block

      This block plays the blocks attached below it when the selected key is released (let go) on the keyboard.


       

      How to Select Different Keys?

      To select a different key, click on the drop-down menu of the block, and then select any key from the Keyboard Pop-up.


       

      What Happens When We Keep a Key Pressed Down?

      If you keep holding a key down, the “When ()Key Pressed” block will be played again and again, as if you are pressing down the key repeatedly.


       

      Demo: Dance Animation with Key Pressed/Released

      Here is how you can use the “When Key Pressed” and “When Key Released” blocks together to start and stop a sprite’s dancing animation.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post