Skip to content

Commit 31eec11

Browse files
committed
add addon support to whenkeyhit
1 parent 1ad1d4c commit 31eec11

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/addons/addons/editor-extra-keys/userscript.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ export default async function ({ addon, msg }) {
7878
return keys;
7979
}
8080

81-
for (const opcode of ["sensing_keyoptions", "event_whenkeypressed"]) {
81+
for (const opcode of ["sensing_keyoptions", "event_whenkeypressed", "event_whenkeyhit"]) {
8282
const block = ScratchBlocks.Blocks[opcode];
8383
const originalInit = block.init;
8484
block.init = function (...args) {
8585
const originalJsonInit = this.jsonInit;
8686
this.jsonInit = function (obj) {
87-
appendKeys(obj.args0[0].options, opcode === "event_whenkeypressed");
87+
appendKeys(obj.args0[0].options, opcode === "event_whenkeypressed" || opcode === "event_whenkeyhit");
8888
return originalJsonInit.call(this, obj);
8989
};
9090
return originalInit.call(this, ...args);
@@ -97,7 +97,7 @@ export default async function ({ addon, msg }) {
9797
if (workspace && flyout) {
9898
const allBlocks = [...workspace.getAllBlocks(), ...flyout.getWorkspace().getAllBlocks()];
9999
for (const block of allBlocks) {
100-
if (block.type !== "event_whenkeypressed" && block.type !== "sensing_keyoptions") {
100+
if (block.type !== "event_whenkeypressed" && block.type !== "event_whenkeyhit" && block.type !== "sensing_keyoptions") {
101101
continue;
102102
}
103103
const input = block.inputList[0];
@@ -110,7 +110,7 @@ export default async function ({ addon, msg }) {
110110
}
111111
field.menuGenerator_ = appendKeys(
112112
defaultKeys ? [...defaultKeys] : field.menuGenerator_,
113-
block.type === "event_whenkeypressed"
113+
block.type === "event_whenkeypressed" || block.type === "event_whenkeyhit"
114114
);
115115
}
116116
}

src/addons/addons/gamepad/userscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async function ({ addon, console, msg }) {
3535
const result = new Set();
3636
for (const blocks of allBlocks) {
3737
for (const block of Object.values(blocks._blocks)) {
38-
if (block.opcode === "event_whenkeypressed" || block.opcode === "sensing_keyoptions") {
38+
if (block.opcode === "event_whenkeypressed" || block.opcode === "event_whenkeyhit" || block.opcode === "sensing_keyoptions") {
3939
// For blocks like "key (my variable) pressed?", the sensing_keyoptions still exists but has a null parent.
4040
if (block.opcode === "sensing_keyoptions" && !block.parent) {
4141
continue;

0 commit comments

Comments
 (0)