Skip to content

Commit

Permalink
Merge pull request #454 from darbicus/master
Browse files Browse the repository at this point in the history
keyisdown fix
  • Loading branch information
Lauren McCarthy committed Dec 8, 2014
2 parents 55c1113 + cd0ff29 commit bc7c20e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ define(function (require) {
'touchstart': null,
'touchmove': null,
'touchend': null,
'resize': null
'resize': null,
'blur': null
};
this._loadingScreenId = 'p5_loading';

Expand Down
9 changes: 9 additions & 0 deletions src/input/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ define(function (require) {
}
}
};
/**
* The onblur function is called when the user is no longer focused
* on the p5 element. Because the keyup events will no fire if the user is
* not focused on the element we must assume all keys currently down have
* been released.
*/
p5.prototype.onblur = function (e) {
downKeys = {};
};

/**
* The keyIsDown function checks if the key is currently down, i.e. pressed.
Expand Down

0 comments on commit bc7c20e

Please sign in to comment.