   []
   (set! (.-onresize js/window) (fn [] (re-render! @app-state)))
 
-  (add-watch app-state :state-changed
-             (fn [_ _ old-state new-state]
-               (when-not (= (:rendering-data old-state)
-                            (:rendering-data new-state))
-                 (re-render! new-state))))
+  (add-watch app-state :state-changed handle-state-change!)
 
   (add-overlay-handlers! (get @app-state :overlay-canvas))
+
+  (set! (.-onkeydown js/window)
+        (fn [e ]
+          (when (and (= (aget e "keyCode") 90)
+                   (aget e "ctrlKey"))
+            (undo!))))
 
   (render-mandelbrot! @app-state))
 

                 (dissoc :mousedown-event)
                 (update-in [:rendering-data] zoom-to-enclose-rectangle! canvas x0 y0 x1 y1))))))

(defn add-overlay-handlers!
  "Adds handlers for zooming to the overlay canvas"
  [overlay-canvas]

  variables for this kind of thing - I got it to be only ~10 times slower using the >> and << macros)"
  [{:keys [canvas overlay-canvas escape-radius]
    {:keys [scale x0 y0] :as render-state} :rendering-data}]

  (set-canvas-dimensions! canvas)
  (set-canvas-dimensions! overlay-canvas)
