 #
 # Note that some keys will only register keydown events and not keystroke events, e.g. ESC.
 #
+
 onKeypress = (event) ->
   keyChar = ""
 

      keyPort.postMessage({ keyChar:"<ESC>", frameId:frameId })

    else if isPassKey KeyboardUtils.getKeyChar(event)
      return Mode.propagate

  # Added to prevent propagating this event to other listeners if it's one that'll trigger a Vimium command.
  # The goal is to avoid the scenario where Google Instant Search uses every keydown event to dump us

      event.srcElement.blur()
    exitInsertMode()
    DomUtils.suppressEvent event
    handledKeydownEvents.push event

  else if (findMode)
    if (KeyboardUtils.isEscape(event))
      handleEscapeForFindMode()
      DomUtils.suppressEvent event
      KeydownEvents.push event

    else if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey)
      handleDeleteForFindMode()
      DomUtils.suppressEvent event
      KeydownEvents.push event

    else if (event.keyCode == keyCodes.enter)
      handleEnterForFindMode()
      DomUtils.suppressEvent event
      KeydownEvents.push event

    else if (!modifiers)
      DomUtils.suppressPropagation(event)
      KeydownEvents.push event

  else if (isShowingHelpDialog && KeyboardUtils.isEscape(event))
    hideHelpDialog()
    DomUtils.suppressEvent event
    KeydownEvents.push event

  else if (!isInsertMode() && !findMode)
    if (keyChar)
      if (currentCompletionKeys.indexOf(keyChar) != -1 or isValidFirstKey(keyChar))
        DomUtils.suppressEvent event
        KeydownEvents.push event

      keyPort.postMessage({ keyChar:keyChar, frameId:frameId })

