 
     # keys must be String or Array
     # Not support Object for keys to avoid ambiguity.
-    element ?= @editorElement
+    target = @editorElement
     mocked = null
     keys = [keys] unless _.isArray(keys)
 
     for k in keys
       if _.isString(k)
-        _keystroke(k, {element})
+        _keystroke(k, {target})
+        continue
       else
         switch
           when k.platform?
-            mockPlatform(element, k.platform)
+            mockPlatform(target, k.platform)
             mocked = true
           when k.char?
             chars =

      expect(@editorElement.classList.contains(m)).toBe(false)

  # Public
  keystroke: (keys, options={}) =>
    {element} = options
    if options.waitsForFinish
      finished = false
      @vimState.onDidFinishOperation -> finished = true

unmockPlatform = (editorElement) ->
  editorElement.parentNode.removeChild(editorElement)

KeymapManager = null
buildKeydownEvent = (key, options) ->
  KeymapManager ?= atom.keymaps.constructor
  KeymapManager.buildKeydownEvent(key, options)

keydown = (key, options) ->
  event = buildKeydownEvent(key, options)
  atom.keymaps.handleKeyboardEvent(event)

_keystroke = (keys, event) ->
  if keys in ['escape', 'backspace']
    keydown(keys, event)
  else
    for key in keys.split('')
      if key.match(/[A-Z]/)
        event.shift = true
      else
        delete event.shift
      keydown(key, event)

isPoint = (obj) ->
  if obj instanceof Point
