diff --git a/packages/jspsych/src/modules/plugin-api/KeyboardListenerAPI.ts b/packages/jspsych/src/modules/plugin-api/KeyboardListenerAPI.ts index 82e1ed7f..6259d82c 100644 --- a/packages/jspsych/src/modules/plugin-api/KeyboardListenerAPI.ts +++ b/packages/jspsych/src/modules/plugin-api/KeyboardListenerAPI.ts @@ -48,7 +48,7 @@ export class KeyboardListenerAPI { private rootKeydownListener(e: KeyboardEvent) { // Iterate over a static copy of the listeners set because listeners might add other listeners // that we do not want to be included in the loop - for (const listener of Array.from(this.listeners)) { + for (const listener of [...this.listeners]) { listener(e); } this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key));