code: function onFocus(cm) {
      if (cm.options.readOnly == "nocursor") return;
      if (!cm.state.focused) {
        signal(cm, "focus", cm);
        cm.state.focused = true;
        addClass(cm.display.wrapper, "CodeMirror-focused");
        // The prevInput test prevents this from firing when a context
        // menu is closed (since the resetInput would kill the
        // select-all detection hack)
        if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
          resetInput(cm);
          if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
        }
      }
      slowPoll(cm);
      restartBlink(cm);
    }
docs: FOCUS/BLUR EVENTS