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>
posted @ 2010-08-26 18:00  与时俱进  阅读(345)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈