用键盘方向键实现翻页

  
    
< script type = " text/javascript " >
document.onkeydown
= nextpage;
var prevpage = " 1.htm " ;
var nextpage = " 3.htm " ;
function nextpage(event)
{
event
= event ? event : (window.event ? window.event : null );
if (event.keyCode == 37 ) location = nextpage; // 方向键→
if (event.keyCode == 39 ) location = prevpage; // 方向键←
//方向键↑为38,方向键↓为40
}
< / script>

你可能感兴趣的:(实现)