         editor  (reset! editor (js/CodeMirror.fromTextArea element cm-opts))]
     (.setValue editor text)
     (when on-change
-      (.on editor "change" on-change))
-    (when on-key-down
-      (.on editor "keydown" on-key-down))))
+      (.on editor "change" on-change))))
 
 (defn cm-will-update [node editor [_ _ text]]
   (debugf "Update")

    true)
  (reset! editor nil))

(defn cm-render [_ text]
  [:textarea {:value text :read-only true}])

(defn codemirror [props text]

      js/CodeMirror.Pass
      (f cm))))

(defn insert-pair [cm pair]
  (debugf "I!")
  (doto cm
    (.replaceSelection "()")
    (.execCommand "goCharLeft")))

(defn editor [props text]
  (let [on-change    (wrap-on-change props)
        history-next (wrap-history-next props)
        history-prev (wrap-history-prev props)
        on-submit    (wrap-on-submit props)
        extra-keys   {:Up         (-> history-prev wrap-ignore-multi)
                      :Down       (-> history-next wrap-ignore-multi)
                      :Ctrl-Up    history-prev
                      :Ctrl-Down  history-next
                      :Enter      (-> on-submit wrap-ignore-multi)
                      :Ctrl-Enter on-submit
                      :Shift-9    #(insert-pair % "()")
                      "["         #(insert-pair % "[]")
                      "Shift-{"   #(insert-pair % "{}")
                      "Shift-'"   #(insert-pair % "\"\"")}]
    (fn []
      [codemirror (-> {:editable?  true
                       :numbers?   false
                       :focus?     true
                       :extra-keys extra-keys
                       :on-change  on-change}
                      (merge (dissoc props :on-change)))
       text])))

(defn code [text]
  [codemirror {:read-only? true :mode "clojure"} text])
