 } = uploadcare
 
 namespace 'uploadcare.widget', (ns) ->
+
+  keyClickable = (el) ->
+    el.on 'click', ->
+        this.blur()
+      .on 'keypress', (e) ->
+        # 13 = Return, 32 = Space
+        if e.which == 13 or e.which == 32
+          $(this).click()
+
   class ns.Template
     constructor: (@settings, @element)->
       @content = $(tpl('widget'))

      @setStatus 'error'

    setFileInfo: (info) ->
      @statusText.html(tpl('widget-file-name', info))
        .find('.uploadcare-widget-file-name')
        .toggleClass('needsclick', @settings.systemDialog)

      @statusText = @content.find('@uploadcare-widget-text')

    addButton: (name, caption='') ->
      keyClickable(
        $(tpl('widget-button', {name, caption}))
          .appendTo(@content)
      )


    setStatus: (status) ->
      prefix = 'uploadcare-widget-status-'
