Skip to content

Commit

Permalink
Update KeyHistory.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium authored Sep 1, 2024
1 parent 1d57104 commit 38d5dd1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions featured/KeyHistory.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Name: Key History
// ID: KeyHistoryExtension
// By: Mistium <https://scratch.mit.edu/users/M1stium>
// Verson: 5
// Verson: 6
// Description: Store a list of previously pressed keys and clipboard events.
// License: MPL-2.0
// This Source Code is subject to the terms of the Mozilla Public License, v2.0,
Expand All @@ -24,6 +24,9 @@
this.keysHit = [];
this.keyHitTimes = [];
this.pause = false;
document.addEventListener("keydown", (event) => this.onKeyDown(event));
document.addEventListener("keyup", (event) => this.onKeyUp(event));
document.addEventListener("paste", (event) => this.onPaste(event));
}

getInfo() {
Expand Down Expand Up @@ -282,16 +285,6 @@
}
}

// Create an instance of the KeyHistoryExtension class
const extension = new KeyHistoryExtension();

// Register the extension with Scratch
Scratch.extensions.register(extension);

// Listen for keydown events and call the onKeyDown method
document.addEventListener("keydown", (event) => extension.onKeyDown(event));
document.addEventListener("keyup", (event) => extension.onKeyUp(event)); // Corrected here

// Listen for paste events and call the onPaste method
document.addEventListener("paste", (event) => extension.onPaste(event));
Scratch.extensions.register(new KeyHistoryExtension());
})(Scratch);

0 comments on commit 38d5dd1

Please sign in to comment.