猿问

如何获取到数字,我就差录制这步没做好,代码不懂得地方已经写上注释

      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;
          };


和你一起闪耀到世界尽头
浏览 1420回答 1
1回答

有的同学

core.music =new Array(); //按下按键的时候 //向数组尾部添加一个元素 core.music.push(0); //播放的时候遍历数组 //值是什么就播放哪个 for(var i = 0, i<= core.music.length; i++) {      core.playSound(core.music[i]);  }是这个意思吗
随时随地看视频慕课网APP
我要回答