为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

      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;           };
查看完整描述

1 回答

?
有的同学

TA贡献31条经验 获得超8个赞

core.music =new Array();
//按下按键的时候
//向数组尾部添加一个元素
core.music.push(0);
//播放的时候遍历数组
//值是什么就播放哪个
for(var i = 0, i<= core.music.length; i++) {
     core.playSound(core.music[i]);
 }

是这个意思吗

查看完整回答
反对 回复 2016-05-18
  • 1 回答
  • 0 关注
  • 1418 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信