Skip to content

Commit

Permalink
Bind 'onKeyPress' during keydown instead of keyup.
Browse files Browse the repository at this point in the history
Binding during keydown will be more effective at preventing certain default behavior like moving the page down as these events may happen prior to keyup. Addresses #1452
  • Loading branch information
songpete committed Aug 27, 2014
1 parent 055d81d commit 58c081f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ vjs.Button.prototype.onClick = function(){};

// Focus - Add keyboard functionality to element
vjs.Button.prototype.onFocus = function(){
vjs.on(document, 'keyup', vjs.bind(this, this.onKeyPress));
vjs.on(document, 'keydown', vjs.bind(this, this.onKeyPress));
};

// KeyPress (document level) - Trigger click when keys are pressed
Expand All @@ -79,5 +79,5 @@ vjs.Button.prototype.onKeyPress = function(event){

// Blur - Remove keyboard triggers
vjs.Button.prototype.onBlur = function(){
vjs.off(document, 'keyup', vjs.bind(this, this.onKeyPress));
vjs.off(document, 'keydown', vjs.bind(this, this.onKeyPress));
};

0 comments on commit 58c081f

Please sign in to comment.