Skip to content

Commit bc7c20e

Browse files
author
Lauren McCarthy
committed
Merge pull request #454 from darbicus/master
keyisdown fix
2 parents 55c1113 + cd0ff29 commit bc7c20e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/core/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ define(function (require) {
166166
'touchstart': null,
167167
'touchmove': null,
168168
'touchend': null,
169-
'resize': null
169+
'resize': null,
170+
'blur': null
170171
};
171172
this._loadingScreenId = 'p5_loading';
172173

src/input/keyboard.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ define(function (require) {
223223
}
224224
}
225225
};
226+
/**
227+
* The onblur function is called when the user is no longer focused
228+
* on the p5 element. Because the keyup events will no fire if the user is
229+
* not focused on the element we must assume all keys currently down have
230+
* been released.
231+
*/
232+
p5.prototype.onblur = function (e) {
233+
downKeys = {};
234+
};
226235

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

0 commit comments

Comments
 (0)