           expect(editor).not.toHaveClass 'command-mode'
           expect(editor).toHaveClass 'insert-mode'
 
-          editor.trigger keydownEvent('escape')
+          keydown('escape', element: editor[0])
 
           editor.setText("one two three four")
           editor.setCursorScreenPosition([0,11])

    it "puts the editor into command mode when <escape> is pressed", ->
      expect(editor).not.toHaveClass 'command-mode'

      editor.trigger keydownEvent('escape')

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

          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])
