     e.preventDefault()
     Prez.current?.end()
 
+$(document).on "keydown", Prez.handlers.keyDown
+
 $ ->
     $("#in-window-not-implemented-modal").modal show: false

    nextSlide: -> @changeSlideBy 1
    prevSlide: -> @changeSlideBy -1
    end: -> @window.close()

$(document).on "click", "#new-window", (e) ->
    return if Prez.current

        $(".prez-slide", @document).each (i) -> $(@).attr "data-slide", "#{i + 1}"
        @changeSlideTo 1 unless changeToHashSlide()
        $(@window).on "hashchange", changeToHashSlide
        $(@document).on "keydown", Prez.handlers.keyDown

    changeSlideTo: (nextValue) ->
        $next = $ ".prez-slide[data-slide='#{nextValue}']", @document
