             :solid false
             })
 
+(def dudeX  (atom 40))
+(def dudeY  (atom 20))
+
 (def width  60)
 (def height 30)
+
+(defn keyHandler [key matches data]
+  (case key
+    "UP"    (swap! dudeY dec)
+    "DOWN"  (swap! dudeY inc)
+    "LEFT"  (swap! dudeX dec)
+    "RIGHT" (swap! dudeX inc)
+    "ESCAPE" (.exit js/process)
+    "meh")
+  (.moveTo      term @dudeX @dudeY "@"))
+
+(defn teardown []
+  (.off term "key" keyHandler))
+
+(defn setup []
+  (.on term "key" keyHandler))
 
 (defn make-block [x y]
   (let [solid (> (rand) 0.9)]

        char    (if solid "." " ")]
    (.color256    term color)
    (.bgColor256  term bgcolor)
    (.moveTo      term x y char)
    ))

(defn show-screen []
  (.clear term)
  (doall (map #(draw-block %) level)))

(defn demo []
  (show-screen)

  (.color256    term 6)
  (.bgColor256  term 4)
  (.moveTo      term 7 7 "@")

  (.color256    term 2)
  (.bgColor256  term 0)
  (.moveTo      term width 25)
)

(demo)

        y (range height)]
    (make-block x y)))

(defonce setup-term
  (do
    (.applicationKeypad term)
    (.hideCursor term)))
