JavaScript 接收键盘指令示例

JavaScript接收键盘指令示例,按下键盘上不同的键,程序会跳转到不同的网页,本例中按下A键程序为跳转到脚本之家的首页,实现按键跳转的功能。
请按下键盘上的A键,会跳转到脚本中文网的首页 
 
<SCRIPT language="JavaScript"> 
<!-- 
var hotkey=97 
var destination="http://www.jsdoc.cnt" 
if (document.layers) 
document.captureEvents(Event.KEYPRESS) 
function backhome(e){ 
if (document.layers){ 
if (e.which==hotkey) 
window.location=destination 
else if (document.all){ 
if (event.keyCode==hotkey) 
window.location=destination 
document.onkeypress=backhome 
onkeydown="javascript:onenter();" 
function onenter(){ 
if(event.keyCode==13){ 
alert("回车"); 
-->
</SCRIPT>
原文地址:https://www.cnblogs.com/top5/p/1809337.html