JavaScript Draw a Rectangle When Screen is Pressed
<p>I am trying to make a simple application using JavaScript that draws a rectangle when I press the screen (On a touch screen). I don't know why it isn't working. Here is the code:</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;canvas id="drawingboard" width="500" height="500" style="border:10px solid #000000;"&gt;
    You have a horrible browser that will not support an HTML canvas, so this won't work.
&lt;/canvas&gt;
</code></pre>

<p><strong>JavaScript</strong></p>

<pre><code>var c = document.getElementById("drawingboard");
var ctx = c.getContext("2d");
var mouseDown = 0;
document.body.ontouchstart = function() { 
  mouseDown+=1;
}
document.body.ontouchend = function() {
  mouseDown-=1;
}
if (mouseDown == 1) {

ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);}
</code></pre>