Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. When Key Pressed/Released Blocks

When Key Pressed/Released Blocks

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.9k Views
  • 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.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Prerequisite

    • Working with Sprites

     

    Description

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

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/105b4a42-56ae-4d60-8d73-c36e8638ba1b.PNG" width="650" style="">
     

    The When () Key Pressed Block

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

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0d157c07-137a-4ee0-8f33-112c392aaffd.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
     

    The When () Key Released Block

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

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/060438c8-bcc1-458b-859a-ceba745f1b1b.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
     

    How to Select Different Keys?

    To select a different key, click on the drop-down menu of the block, https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/464157d5-d9ff-486b-80bb-dcd271af8226.PNG" width="170" style=""> and then select any key from the Keyboard Pop-up.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d7ba2cd2-c26f-4761-a2f5-bb55d32aa468.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
     

    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.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ec2e25a0-8342-4e99-aa83-281fe8c240e6.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
     

    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.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7458b3f4-4238-4a24-bab1-e17cc3e79c81.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode