     caption = event.target.value
     @delegate?.attachmentEditorDidRequestUpdatingAttachmentWithAttributes?(@attachment, {caption})
 
+  didKeyDownCaption: (event) =>
+    if keyNames[event.keyCode] is "return"
+      event.preventDefault()
+      @didChangeCaption(event)
+      @uninstall()
+
   uninstall: ->
     undo() while undo = @undos.pop()
     @delegate?.didUninstallAttachmentEditor(this)

    input.setAttribute("placeholder", Trix.config.lang.attachment.captionPlaceholder)
    input.value = @attachmentPiece.getCaption()

    handleEvent("change", onElement: input, withCallback: @didChangeCaption)

    figcaption = @element.querySelector("figcaption")

#= require trix/controllers/attachment_editor_controller

{handleEvent, makeElement, tagName} = Trix
{keyNames} = Trix.InputController

class Trix.AttachmentEditorController extends Trix.BasicObject
  constructor: (@attachmentPiece, @element, @container) ->
