I think the following could award me 10 points:
http://ideone.com/YBD7xy
It adds and event listener like this:
window.addEventListener( "keydown", doKeyDown, true);
doKeyDown is executed upon a "keydown"-event
function doKeyDown(e)
{
if (e.keyCode != 32) // 32 is code for space bar key
return;
if (g_id == 0){
g_sx = g_canvas.width / 2;
// Here you could determine, where on the y-axis the square would start drawing
// g_sy = 0;
g_id = setInterval(rectLoop, s_interval);
}
else {
window.clearInterval(g_id);
g_id = 0;
}
}
for the square and for the circle there are now two separate sets of global variables.
I hope this helps.