Q:

How do I reuse this JavaScript timeout closure? 

I found the following piece of JavaScript code (maybe here at Stack Overflow?)  for implementing a timeout:
var delay = (function() {
  var timer = 0;
  return function(callback, ms) {
    clearTimeout(timer);
    timer = setTimeout(callback, ms);
  };
})();

I'm new to JavaScript, so I'm still trying to wrap my head around closures.  If I call delay(firstCallback, 200) in one place and then delay(secondCallback, 200) right after, the first timeout callback is cleared, while the second callback executes successfully. 
How do I reuse delay in different instances without overwriting other instances? ( Not sure if those terms are correct, but hopefully it gets my point across.)  So, in the above example, I want both callbacks to execute. 
Thanks for your help! 
EDIT: As a practical example, I'm trying to buffer keypress events on an input field, so that the callback is only executed after no key has been pressed for 200ms.  But I have multiple input fields, and currently the buffer breaks when two input fields have keypress events in quick succession. 

A:

To reuse this, it is easier to get rid of the anonymous function and use it as a generator. 
var createDelayManager = function() {
  var timer = 0;
  return function(callback, ms) {
     clearTimeout(timer);
     timer = setTimeout(callback, ms);
  };
}

var delayManagerOne = createDelayManager();
delayManagerOne(firstCallback, 200);

var delayManagerTwo = createDelayManager();
delayManagerTwo(secondCallback, 200);

Here is a working fiddle:
http://jsfiddle.net/HJrM7/
But, It is worth noting, that the point of this closure is to prevent multiple callbacks from getting stacked against some object.  It is a really nice closure though that enables you to make sure that the last event triggered will be the one that gets acted on.  I use this technique a lot to prevent flickering, or unwanted mouse out events during ie redraws.