mosaicode/extensions/javascript/blocks/webaudio/Input Device/Keyboard.json

37 lines
1.6 KiB
JSON

{
"source": "JSON",
"data": "BLOCK",
"version": "0.0.1",
"type": "javascript.input devices.keyboard",
"language": "javascript",
"extension": "webaudio",
"help": "Keyboard",
"label": "Keyboard",
"color": "#4283FA",
"group": "Input Device",
"codes": [
{
"name": "function",
"code": "\nvar keyboard_char_output = [];\nvar keyboard_float_output = [];\ndocument.onkeypress = function(evt){\n evt = evt || window.event;\n\n var value = evt.keyCode || evt.which;\n for (var i = 0; i < keyboard_float_output.length ; i++)\n for (var j = 0; j < keyboard_float_output[i].length ; j++)\n keyboard_float_output[i][j](value);\n\n value = String.fromCharCode(value);\n for (var i = 0; i < keyboard_char_output.length ; i++)\n for (var j = 0; j < keyboard_char_output[i].length ; j++)\n keyboard_char_output[i][j](value);\n};\n"
},
{
"name": "declaration",
"code": "\n// block_$id$ = KeyBoard Input\nvar $port[char_output]$ = [];\nvar $port[float_output]$ = [];\nkeyboard_char_output.push($port[char_output]$);\nkeyboard_float_output.push($port[float_output]$);\n"
}
],
"properties": [],
"ports": [
{
"conn_type": "output",
"name": "float_output",
"label": "Float Output",
"type": "javascript.float"
},
{
"conn_type": "output",
"name": "char_output",
"label": "Char Output",
"type": "javascript.char"
}
]
}