Update sensing.js

This commit is contained in:
radmanplays 2024-04-17 18:41:20 +03:30 committed by GitHub
commit d0a252739c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,37 +6,6 @@ const categoryPrefix = 'sensing_';
const categoryColor = '#5CB1D6';
function register() {
registerBlock(`${categoryPrefix}keydown`, {
message0: 'when key %1 is down %2 %3',
args0: [
{
"type": "field_input",
"name": "KEY",
"spellcheck": false
},
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "BLOCKS"
}
],
nextStatement: null,
inputsInline: true,
colour: categoryColor,
extensions: [
'single_character_validation',
],
}, (block) => {
const KEY = block.getFieldValue('KEY')
const BLOCKS = javascriptGenerator.statementToCode(block, 'BLOCKS');
const code = `window.addEventListener("keydown", event => {
if (event.key == '${KEY}') { ${BLOCKS} }
});`;
return `${code}\n`;
})
// alert
registerBlock(`${categoryPrefix}alert`, {
message0: 'alert %1',