<div class="htmlarea"> <textarea id="runcode35323"> <script language="JavaScript"> <!-- var dn=0; //1 up, 2 left, 3 both document.onkeyup = function() { if(event.keyCode== 37) { if(dn==2) { dn=0 } else if(dn==3){dn=1} } if(event.keyCode== 38) { if(dn==1){dn=0} else if(dn==3){dn=2} } } document.onkeydown = function() { if(event.keyCode== 37) { ren.innerText="aa"//向左 if(dn==0){dn=2} else if(dn==1){dn=3} } else if(event.keyCode==38) { ren.innerText="bb"//向上 if(dn==0){dn=1} else if(dn==2){dn=3} } if(dn==3) { dn=0 alert("cc") } } //--> </script> <div id="ren"></div> </textarea><br><input onclick="runEx('runcode35323')" type="button" value="运行代码"> <input onclick="doCopy('runcode35323')" type="button" value="复制代码"> <input onclick="doSave(runcode35323)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>