title: Single click and Double click on the same element, not working; Javascript
body: <p>I am trying to add a click function that triggers when a button is clicked. I am also trying to figure out how to add a double click function onto the same element, that triggers a different event.</p>
  
  <pre><code>var click = false;
  onEvent("image2", "click", function(event) {
    click = true;
  });
  if (click === true) {
    setTimeout(function() {
      onEvent("image2", "click", function(event) {
        setScreen("safeScreen");
        console.log("double click");
      });
    }, 200);
  } else {
    onEvent("image2", "dblclick", function(event) {
      setScreen("safeScreen");
      console.log("click");
    });
  }
  </code></pre>
  
  <p>This code is completely wrong, but I don't know where to start/correct. What am I doing wrong? I am looking to have the single click not trigger when the user double clicks.</p>