File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -441,11 +441,13 @@ p5.prototype.keyCode = 0;
441
441
* </div>
442
442
*/
443
443
p5 . prototype . _onkeydown = function ( e ) {
444
+ // Ignore repeated key events when holding down a key
444
445
if ( e . repeat ) {
445
- // Ignore repeated key events when holding down a key
446
+ this . _setProperty ( 'isKeyRepeated' , true ) ;
446
447
return ;
447
448
}
448
449
450
+ this . _setProperty ( 'isKeyRepeated' , false ) ;
449
451
this . _setProperty ( 'isKeyPressed' , true ) ;
450
452
this . _setProperty ( 'keyIsPressed' , true ) ;
451
453
this . _setProperty ( 'keyCode' , e . which ) ;
@@ -781,7 +783,7 @@ p5.prototype._onkeyup = function(e) {
781
783
* </div>
782
784
*/
783
785
p5 . prototype . _onkeypress = function ( e ) {
784
- if ( e . which === this . _lastKeyCodeTyped ) {
786
+ if ( e . which === this . _lastKeyCodeTyped && this . isKeyRepeated ) {
785
787
// prevent multiple firings
786
788
return ;
787
789
}
You can’t perform that action at this time.
0 commit comments