色www,五月婷婷深爱五月,午夜国产一级片,色噜噜综合,国产大胸无码视频,清纯美女被操黄网站在线观看,波多野结衣av高清一区二区三区

利用JS來(lái)控制鍵盤(pán)的上下左右鍵

時(shí)間:2025-11-14 13:05:33 計(jì)算機(jī)硬件

利用JS來(lái)控制鍵盤(pán)的上下左右鍵

  主要介紹了利用JS來(lái)控制鍵盤(pán)的上下左右鍵示例代碼。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助

利用JS來(lái)控制鍵盤(pán)的上下左右鍵

  這是一個(gè)JS初級(jí)代碼,想學(xué)JS的朋友,可以研究下或者擴(kuò)展下,最好能用JS實(shí)現(xiàn)整個(gè)鍵盤(pán)的控制,那感覺(jué)就很有意思了。

  具體代碼如下:

  代碼如下:

  <style>

  tr.highlight{background:#08246B;color:white;}

  </style>

  <table border="1" width="70%" id="ice">

  <tr>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  </tr>

  <tr>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  </tr>

  <tr>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  </tr>

  <tr>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  </tr>

  <tr>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  <td><input type='text'></td>

  </tr>

  </table>

  <script language="javascript">

  <!--

  /pic/p>

  var currentLine=-1;

  var currentCol=-1;

  document.onkeydown=function(e){

  e=window.event||e;

  switch(e.keyCode){

  case 37: /pic/p>

  currentCol--;

  changeItem();

  break;

  case 38: /pic/p>

  currentLine--;

  changeItem();

  break;

  case 39: /pic/p>

  currentCol++;

  changeItem();

  break;

  case 40: /pic/p>

  currentLine++;

  changeItem();

  break;

  default:

  break;

  }

  }

  /pic/p>

  function changeItem(){

  if(document.all)

  var it=document.getElementByIdx_x("ice").children[0];

  else

  var it=document.getElementByIdx_x("ice");

  for(i=0;i<it.rows.length;i++){

  it.rows[i].className="";

  }

  if(currentLine<0){

  currentLine=it.rows.length-1;

  }

  if(currentLine==it.rows.length){

  currentLine=0;

  }

  var objtab=document.all.ice;

  var objrow=objtab.rows[currentLine].getElementsByTagName_r("INPUT");

  if(currentCol<0){

  currentCol=objrow.length-1;

  }else if(currentCol==objrow.length){

  currentCol=0;

  }

  objrow[currentCol].select();

  /pic/p>

  it.rows[currentLine].className="highlight";

  }

  /pic/p>

  </script>

【利用JS來(lái)控制鍵盤(pán)的上下左右鍵】相關(guān)文章:

鍵盤(pán)Win鍵在哪里12-09

鍵盤(pán)上哪個(gè)鍵是截圖02-21

電腦鍵盤(pán)快捷鍵08-19

電腦鍵盤(pán)space鍵的作用02-19

電腦鍵盤(pán)home鍵的作用02-04

鍵盤(pán)Alt鍵有什么功能09-04

臺(tái)式電腦鍵盤(pán)的快捷鍵02-17

鍵盤(pán)上的鍵都有哪些用途11-26

電腦鍵盤(pán)Alt鍵使用技巧12-03