title: Checking input in Meteor
body: <p>I am trying to understand Todos example in Meteor. There's a piece of code that I can't make sense of:</p>
  
  <pre><code>// Returns an event map that handles the "escape" and "return" keys and
  // "blur" events on a text input (given by selector) and interprets them
  // as "ok" or "cancel".
  var okCancelEvents = function (selector, callbacks) {
    var ok = callbacks.ok || function () {};
    var cancel = callbacks.cancel || function () {};
  
    var events = {};
    events['keyup '+selector+', keydown '+selector+', focusout '+selector] =
      function (evt) {
        if (evt.type === "keydown" &amp;&amp; evt.which === 27) {
          // escape = cancel
          cancel.call(this, evt);
  
    } else if (evt.type === "keyup" &amp;&amp; evt.which === 13 ||
               evt.type === "focusout") {
      // blur/return/enter = ok/submit if non-empty
      var value = String(evt.target.value || "");
      if (value)
        ok.call(this, value, evt);
      else
        cancel.call(this, evt);
    }
  };
    return events;
  };
  </code></pre>
  
  <p>What does <code>events['keyup '+selector+', keydown '+selector+', focusout '+selector] = function(){}</code> yield?</p>
  
  <p>Why do we need to convert to string the following: <code>String(evt.target.value || "")</code>?</p>
  
  <p>Does evt argument of the said function have to have .type, .target and .target.value? What I can pass in evt?</p>