script.js
来自「lynda.com 2007年出品的javascript essential t」· JavaScript 代码 · 共 39 行
JS
39 行
document.onkeydown = keyHit;var thisPic = 0;function keyHit(evt) { var myPix = new Array("images/callisto.jpg","images/europa.jpg","images/io.jpg","images/ganymede.jpg"); var imgCt = myPix.length-1; var ltArrow = 37; var rtArrow = 39; var thisKey; if (evt) { thisKey = evt.which; } else { thisKey = window.event.keyCode; } if (thisKey == ltArrow) { chgSlide(-1); } else { if (thisKey == rtArrow) { chgSlide(1); } } return false; function chgSlide(direction) { thisPic = thisPic + direction; if (thisPic > imgCt) { thisPic = 0; } if (thisPic < 0) { thisPic = imgCt; } document.getElementById("myPicture").src = myPix[thisPic]; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?