diff --git a/src/events/keyboard.js b/src/events/keyboard.js index 0e51b0632c..da9e1b9315 100644 --- a/src/events/keyboard.js +++ b/src/events/keyboard.js @@ -780,6 +780,12 @@ function keyboard(p5, fn, lifecycles){ * } */ fn._onkeyup = function(e) { + this.key = e.key; + this.code = e.code; + + delete this._downKeyCodes[e.code]; + delete this._downKeys[e.key]; + if (typeof this._customActions.keyReleased === 'function') { const executeDefault = this._customActions.keyReleased(e); if (executeDefault === false) { @@ -787,10 +793,6 @@ function keyboard(p5, fn, lifecycles){ } } - delete this._downKeyCodes[e.code]; - delete this._downKeys[e.key]; - - if (!this._areDownKeys()) { this.keyIsPressed = false; this.key = ''; @@ -802,7 +804,6 @@ function keyboard(p5, fn, lifecycles){ const lastPressedKey = Object.keys(this._downKeys).pop(); this.key = lastPressedKey; } - }; /**