       console.error "Error setting up Medium:", err
       throw err
 
-    @elem.addEventListener "keyup", @handleKeyup
+    @elem.addEventListener "keydown", @handleKeydown
 
     @enableMutationObserver()
 

# 2. Writes to the element when requested, optionally while disabling the 
#    mutation observer to avoid spurious updates.
Medium = require "./medium.js"

module.exports = class Editor
  constructor: (@elem, @mutationObserverOptions, enableRichText, @onChange) ->

onWriteError = (err) ->
  console.error "Error while trying to write to editor", err
  throw new Error err

getCaretOffset = ->
  window.getSelection().getRangeAt(0)?.startOffset
