home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
3.28
  • Packages
    • @ember/application
    • @ember/array
    • @ember/canary-features
    • @ember/component
    • @ember/component/template-only
    • @ember/controller
    • @ember/debug
    • @ember/destroyable
    • @ember/engine
    • @ember/error
    • @ember/helper
    • @ember/object
    • @ember/polyfills
    • @ember/routing
    • @ember/runloop
    • @ember/service
    • @ember/string
    • @ember/template
    • @ember/test
    • @ember/utils
    • @glimmer/component
    • @glimmer/tracking
    • @glimmer/tracking/primitives/cache
    • rsvp
  • Classes
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Checkbox
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • Controller
    • CoreObject
    • DataAdapter
    • Ember.EmberENV
    • Ember.Error
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberObject
    • EmberRouter
    • Engine
    • EngineInstance
    • EventTarget
    • Evented
    • HashLocation
    • Helper
    • HistoryLocation
    • LinkComponent
    • Mixin
    • MutableArray
    • NoneLocation
    • ObjectProxy
    • Observable
    • Promise
    • PromiseProxyMixin
    • Route
    • RouteInfo
    • RouteInfoWithAttributes
    • RouterService
    • Service
    • String
    • TestAdapter
    • TextArea
    • TextField
    • Transition

Class Ember.TextSupport private


Extends: Mixin
Uses: Ember.TargetActionSupport
Defined in: packages/@ember/-internals/views/lib/mixins/text_support.js:21
Module: ember

TextSupport is a shared mixin used by both TextField and TextArea. TextSupport adds a number of methods that allow you to specify a controller action to invoke when a certain event is fired on your text field or textarea. The specified controller action would get the current value of the field passed in as the only argument unless the value of the field is empty. In that case, the instance of the field itself is passed in as the only argument.

Let's use the pressing of the escape key as an example. If you wanted to invoke a controller action when a user presses the escape key while on your field, you would use the escape-press attribute on your field like so:

  {{! application.hbs}}

  {{input escape-press='alertUser'}}
    import Application from '@ember/application';
    import Controller from '@ember/controller';
    App = Application.create();

    App.ApplicationController = Controller.extend({
      actions: {
        alertUser: function ( currentValue ) {
          alert( 'escape pressed, current value: ' + currentValue );
        }
      }
    });

The following chart is a visual representation of what takes place when the escape key is pressed in this scenario:

The Template
+---------------------------+
|                           |
| escape-press='alertUser'  |
|                           |          TextSupport Mixin
+----+----------------------+          +-------------------------------+
     |                                 | cancel method                 |
     |      escape button pressed      |                               |
     +-------------------------------> | checks for the `escape-press` |
                                       | attribute and pulls out the   |
     +-------------------------------+ | `alertUser` value             |
     |     action name 'alertUser'     +-------------------------------+
     |     sent to controller
     v
Controller
+------------------------------------------ +
|                                           |
|  actions: {                               |
|     alertUser: function( currentValue ){  |
|       alert( 'the esc key was pressed!' ) |
|     }                                     |
|  }                                        |
|                                           |
+-------------------------------------------+

Here are the events that we currently support along with the name of the attribute you would need to use on your field. To reiterate, you would use the attribute name like so:

  {{input attribute-name='controllerAction'}}
+--------------------+----------------+
|                    |                |
| event              | attribute name |
+--------------------+----------------+
| new line inserted  | insert-newline |
|                    |                |
| enter key pressed  | enter          |
|                    |                |
| cancel key pressed | escape-press   |
|                    |                |
| focusin            | focus-in       |
|                    |                |
| focusout           | focus-out      |
|                    |                |
| keypress           | key-press      |
|                    |                |
| keyup              | key-up         |
|                    |                |
| keydown            | key-down       |
+--------------------+----------------+


Methods

Properties

On this page


Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2026 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.