 
 ;; events->chan on keyboard -> println the event (check it's not duplicated)
 
+(defn fullscreen-handler
+  [canvas e]
+  (when (= (.-keyCode e)
+           fullscreen-keycode)
+    (when (fullscreen/isSupported)
+      (println "fullscreen is supported")
+      (if (fullscreen/isFullScreen)
+        (fullscreen/exitFullScreen)
+        (fullscreen/requestFullScreen canvas)))))
+
 (defn boot-game
   []
   (let [canvas (game-surface)

  (:require [cljs.core.async :as async
             :refer [>! <! put! chan alts! timeout]]
            [clojure.set :refer [difference]]
            [kindness.gamepad :as gamepad]
            [kindness.utils :as utils])
  (:import [goog.events EventType]))

          control-chan (if (= v :close)
                         (do
                           (utils/stop-events keyboard-event-key)
                           (utils/stop-events fullscreen-key)
                           (println "Control closed"))
                         (recur last-state))
          rafchan (do (utils/record-render-time v)
                      (gamepad-move (gamepad/raw-gamepads))
                      (run-systems v)
                      (when (or (not= last-state @game-state)
                                (> v 100))
                        (render-entities))
                      (recur @game-state)))))))

