title: mouse speed javascript function
body: <p>Working on some javascript. I found a pretty good function that calculates the speed of the cursor. The problem is that i want to return the actual value, not a callback. How would you do that?</p>
  
  <pre><code>        function makeVelocityCalculator(e_init, callback) {
          var x = e_init.clientX,
              y = e_init.clientY,
              t = Date.now();
          return function(e) {
              var new_x = e.clientX,
                  new_y = e.clientY,
                  new_t = Date.now();
              var x_dist = new_x - x,
                  y_dist = new_y - y,
                  interval = new_t - t;
              // update values:
              x = new_x;
              y = new_y;
              t = new_t;
              var velocity = Math.sqrt(x_dist*x_dist+y_dist*y_dist)/interval;
              callback(velocity);
          };
      }
  </code></pre>