 
 (defn player [state dispatch]
   (let [{:keys [font-size theme lines stop-playback-chan current-time duration loading frames]} @state
-        on-key-press (partial handle-event map-key-press dispatch)
-        on-key-down (partial handle-event map-key-down dispatch)
+        on-key-press (partial handle-dom-event dispatch key-press->event)
+        on-key-down (partial handle-dom-event dispatch key-down->event)
         class-name (player-class-name theme)
         playing? (boolean stop-playback-chan)]
     [:div.asciinema-player-wrapper {:tab-index -1 :on-key-press on-key-press :on-key-down on-key-down}

    "9" [:seek 0.9]
    nil))

(defn map-key-down [dom-event]
  (case (.-which dom-event)
    37 [:rewind]
    39 [:fast-forward]


(defn player-style [] {})

(defn handle-dom-event [dispatch event-mapper dom-event]
  (when-let [[event-name & _ :as event] (event-mapper dom-event)]
    (.preventDefault dom-event)
    (if (= event-name :toggle-fullscreen) ; has to be processed synchronously
      (fullscreen/toggle (.-currentTarget dom-event))
      (dispatch event))))

(defn key-press->event [dom-event]
  (case (.-key dom-event)
    " " [:toggle-play]
    "f" [:toggle-fullscreen]
