     it "puts the editor into command mode when <escape> is pressed", ->
       expect(editor).not.toHaveClass 'command-mode'
 
-      editor.trigger keydownEvent('escape')
+      keydown('escape', element: editor[0])
 
       expect(editor).toHaveClass 'command-mode'
       expect(editor).not.toHaveClass 'insert-mode'


  describe "insert-mode", ->
    beforeEach ->
      editor.trigger keydownEvent('i')

    it "allows the cursor to reach the end of the line", ->
      editor.setText("012345\n\nabcdef")

          expect(editor).not.toHaveClass 'command-mode'
          expect(editor).toHaveClass 'insert-mode'

          keydown('escape', element: editor[0])

          editor.setText("one two three four")
          editor.setCursorScreenPosition([0,0])
