code: function (event) {
  
              if (!event.ctrlKey && !event.metaKey) {
  
                  var keyCode = event.keyCode;
  
                  if ((keyCode >= 33 && keyCode <= 40) || (keyCode >= 63232 && keyCode <= 63235)) {
                      // 33 - 40: page up/dn and arrow keys
                      // 63232 - 63235: page up/dn and arrow keys on safari
                      setMode("moving");
                  }
                  else if (keyCode == 8 || keyCode == 46 || keyCode == 127) {
                      // 8: backspace
                      // 46: delete
                      // 127: delete
                      setMode("deleting");
                  }
                  else if (keyCode == 13) {
                      // 13: Enter
                      setMode("newlines");
                  }
                  else if (keyCode == 27) {
                      // 27: escape
                      setMode("escape");
                  }
                  else if ((keyCode < 16 || keyCode > 20) && keyCode != 91) {
                      // 16-20 are shift, etc. 
                      // 91: left window key
                      // I think this might be a little messed up since there are
                      // a lot of nonprinting keys above 20.
                      setMode("typing");
                  }
              }
          }
docs: Set the mode depending on what is going on in the input area.