Skip to content

Commit 661c4d5

Browse files
committed
onblur function
1 parent edabfc2 commit 661c4d5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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)