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 6, 2024
1 parent b131106 commit 62dede8
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions featured/KeyHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
document.addEventListener("keydown", (event) => this.onKeyDown(event));
document.addEventListener("keyup", (event) => this.onKeyUp(event));
document.addEventListener("paste", (event) => this.onPaste(event));
console.log("Key History Extension Loaded");
}

getInfo() {
Expand Down Expand Up @@ -101,24 +102,6 @@
text: "disable key history",
},
"---",
{
opcode: "onKeyPressed",
blockType: Scratch.BlockType.EVENT,
text: "when key is pressed",
isEdgeActivated: false,
},
{
opcode: "onKeyReleased",
blockType: Scratch.BlockType.EVENT,
text: "when key is released",
isEdgeActivated: false,
},
{
opcode: "onTextPasted",
blockType: Scratch.BlockType.EVENT,
text: "when text is pasted",
isEdgeActivated: false,
},
{
opcode: "lastKeyPressed",
blockType: Scratch.BlockType.REPORTER,
Expand Down Expand Up @@ -182,8 +165,6 @@
}

onKeyDown(event) {
Scratch.vm.runtime.startHats('KeyHistoryExtension_onKeyPressed');

const key = Scratch.Cast.toString(event.key ?? "");
const lowerkey = key.toLowerCase();
if (!this.keysHit.includes(lowerkey)) {
Expand All @@ -204,8 +185,6 @@
}

onKeyUp(event) {
Scratch.vm.runtime.startHats('KeyHistoryExtension_onKeyReleased');

// Convert the key to a string to ensure consistency
const key = Scratch.Cast.toString(event.key ?? "").toLowerCase();
const lowerkey = key.toLowerCase();
Expand All @@ -226,7 +205,6 @@


onPaste(event) {
Scratch.vm.runtime.startHats('KeyHistoryExtension_onTextPasted');
const pastedText = event.clipboardData.getData("text/plain");
this.addKeyToHistory(Scratch.Cast.toString(pastedText));
}
Expand Down

0 comments on commit 62dede8

Please sign in to comment.