diff --git a/src/js/text-field.jsx b/src/js/text-field.jsx index 2b073f2a0c8f25..ee501f6448406a 100644 --- a/src/js/text-field.jsx +++ b/src/js/text-field.jsx @@ -16,6 +16,8 @@ var TextField = React.createClass({ onBlur: React.PropTypes.func, onChange: React.PropTypes.func, onFocus: React.PropTypes.func, + onKeyDown: React.PropTypes.func, + onEnterKeyDown: React.PropTypes.func, type: React.PropTypes.string }, @@ -102,7 +104,8 @@ var TextField = React.createClass({ className: 'mui-text-field-input', id: inputId, onBlur: this._handleInputBlur, - onFocus: this._handleInputFocus + onFocus: this._handleInputFocus, + onKeyDown: this._handleInputKeyDown }; if (!this.props.hasOwnProperty('valueLink')) { @@ -191,6 +194,11 @@ var TextField = React.createClass({ if (this.props.onFocus) this.props.onFocus(e); }, + _handleInputKeyDown: function(e) { + if (e.keyCode === 13 && this.props.onEnterKeyDown) this.props.onEnterKeyDown(e); + if (this.props.onKeyDown) this.props.onKeyDown(e); + }, + _handleTextAreaHeightChange: function(e, height) { var newHeight = height + 24; if (this.props.floatingLabelText) newHeight += 24;