<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Check if the mouse button is pressed down]]></title><description><![CDATA[<h2><a class="anchor-offset" name="introduction"></a>Introduction</h2>
<p dir="auto">You can check if any mouse button is pressed down on the stage window using the following boolean block in the sensing category:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a59986bb-bc69-4a59-a6ac-95b579e02687.png" width="400" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto">If the mouse button is pressed down and the pointer is inside the stage window at the moment this block is played, then it will report “true”; otherwise, it will report “false”.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/34522bcb-dca3-414b-bccd-ee3a6a58eeef.gif" alt="p.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="a-common-mistake"></a>A Common Mistake</h2>
<p dir="auto">One common mistake is to check for the mouse press in a single “if” block like this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2b0b52c2-4cb7-4641-a43c-c85ec5864866.gif" alt="p.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto">This won’t work because the program will run through the “if” and “mouse down?” blocks very quickly when you click the green flag button. Therefore, if you press down the mouse button after clicking the green flag, <strong><span style="color:#fa0000">the program will not respond to you, because it has already ended</span></strong>.</p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="combined-with-forever-if"></a>Combined with Forever + If</h2>
<p dir="auto">Most of the time, the correct way is to use the “mouse down?” block together with a forever block and an “if” block. This way, <strong>the program will repeatedly check if the mouse is pressed down</strong>.</p>
<p dir="auto">For example, we can turn the ball when the mouse is pressed down like this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4655c1f2-30cd-4f15-a7e8-beb500a8a5c4.gif" alt="p.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
Note that you can press down the mouse anywhere on the stage to make this block report true. You do not need to click on the sprite.</p>
]]></description><link>https://forum.creaticode.com/topic/668/check-if-the-mouse-button-is-pressed-down</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 04:23:05 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/668.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Sep 2022 17:16:16 GMT</pubDate><ttl>60</ttl></channel></rss>