var core = { music: [],//存放音乐的变量 record: false, apiUrl: "api/", audio: new Audio(), api: null, document.onkeydown = function (event) { var keyCode = ""; var pressEvent = event || window.event; if(pressEvent.keyCode){ keyCode = pressEvent.keyCode; }else if(pressEvent.charCode){ keyCode = pressEvent.charCode; }else{ keyCode = pressEvent.which; } switch (keyCode){ case 65: //a core.playSound(0); break; case 87: //w core.playSound(8); break; case 83: //s core.playSound(1); break; case 69: //e core.playSound(9); break; case 68: //d core.playSound(2); break; case 70: //f core.playSound(10); break; case 84: //t core.playSound(3); break; case 71: //g core.playSound(11); break; case 89: //y core.playSound(4); break; case 72: // h core.playSound(12); break; case 85: // u core.playSound(5); break; case 74: // j core.playSound(6); break; case 75: // k core.playSound(7); break; default : break; } }; } document.getElementById("record").onclick = function () { // alert("test"); 求指导这里,差一点代码 core.music = [];//把0-11的数字放进去就是录制的东西(0,1,2,3,4,5,6,8,9,10) core.record = true; };
有的同学