Clear key press buffer on stop button

This commit is contained in:
Eric Rosenbaum 2018-12-09 23:13:55 -05:00
parent ebe06a97d9
commit a785b86949

View file

@ -86,6 +86,9 @@ class Scratch3MakeyMakeyBlocks {
this.keyPressed = this.keyPressed.bind(this);
this.runtime.on('KEY_PRESSED', this.keyPressed);
this._clearkeyPressBuffer = this._clearkeyPressBuffer.bind(this);
this.runtime.on('PROJECT_STOP_ALL', this._clearkeyPressBuffer);
/*
* An object containing a set of sequence objects.
* These are the key sequences currently being detected by the "when
@ -337,6 +340,13 @@ class Scratch3MakeyMakeyBlocks {
}
}
/**
* Clear the key press buffer.
*/
_clearkeyPressBuffer () {
this.keyPressBuffer = [];
}
/*
* Add a key sequence to the set currently being checked on each key press.
* @param {string} sequenceString a string of space-separated KEY_IDs.