Skip to content

Commit

Permalink
Spacebar key up triggers button clicks. Fixes #155
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Nguyen committed Dec 29, 2014
1 parent d62c507 commit d18b175
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/enhanced-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var EnhancedButton = React.createClass({
},

windowListeners: {
'keydown': '_handleWindowKeydown',
'keyup': '_handleWindowKeyup'
},

Expand Down Expand Up @@ -96,13 +97,19 @@ var EnhancedButton = React.createClass({
return this.state.isKeyboardFocused;
},

_handleWindowKeyup: function(e) {
_handleWindowKeydown: function(e) {
if (e.keyCode == KeyCode.TAB) this._tabPressed = true;
if (e.keyCode == KeyCode.ENTER && this.state.isKeyboardFocused) {
this._handleTouchTap(e);
}
},

_handleWindowKeyup: function(e) {
if (e.keyCode == KeyCode.SPACE && this.state.isKeyboardFocused) {
this._handleTouchTap(e);
}
},

_handleBlur: function(e) {
this.setState({
isKeyboardFocused: false
Expand Down
1 change: 1 addition & 0 deletions src/js/utils/key-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
ENTER: 13,
LEFT: 37,
RIGHT: 39,
SPACE: 32,
TAB: 9,
UP: 38
}

0 comments on commit d18b175

Please sign in to comment.