当前位置:首页 > 网页特效 > 游戏特效 >

JS网页版的键位指法练习软件源代码

时间:2014-06-08 23:25 来源:互联网 作者:源码搜藏 收藏 推荐

运行代码 保存代码 复制代码 提示:您可以先修改部分代码再运行,保存代码功能在Firefox下无效。
  • 很不错的基于JS的网页指法练习软件,想学JS的朋友有必要看一下代码,有很多值得我们学习的。
  • <script language="javascript">
    var var1,word,killword,rig02=0,err02=0,num=0,num2=0,numper=0
    function sysword()
    {
    word="QWERTYUIOPLKJHGFDSAZXCVBNM".charAt(Math.floor(Math.random()*26));
    document.getElementById(word).style.background="pink"
    sys.innerText=word;
    }
    sysword()
     
    document.onkeydown=function()
    {
    var1=String.fromCharCode(event.keyCode)
    if(var1==word)
    {
    rig.innerText=(++rig02)
    }
    else
    {
    err.innerText=(++err02)
    diverr.style.visibility="visible"
    setTimeout("diverr.style.visibility='hidden'",500)
     
    }
     
    document.getElementById(word).style.background="#fffff0"
    if(/[^A-Z]/g.test(var1))
    {
    alert("请按字母键!");
    }
    else
    {
    document.getElementById(var1).style.background="red";
    sysword();
    }
    }
     
    document.onkeyup=function()
    {
    document.getElementById(var1).style.background="#fffff0";
    num=rig02+err02
    num2=rig02/num
    num2=num2*100
    num2=Math.round(num2)
    spanpercent.innerText=num2+"%"
    numper=num/vartime
    numper=numper*10
    numper=Math.round(numper)
    numper=numper/10
    spanspeed.innerText=numper
     
    }
    var vartime=0
    setInterval("spantime.innerText=(++vartime)",1000)
    </script>
由源码搜藏网整理,转载请注明出处https://www.codesocang.com/tx-youxi/8625.html
上一篇:jQuery掷色子动画
下一篇:JavaScript五子棋

游戏特效下载排行

最新文章