lab.html
<html> <script type="text/javascript" src="keyenter.js"></script> <script language="javascript"> /* aler発行 */ function onclickFunc(){ alert("aa"); } </script> <form name = "form1"> <input type="text" tabindex="1"> <input type="text" tabindex="2"> diable→<input type="text" tabindex="3" disabled> <input type="text" tabindex="4" > <input type="button" onclick="onclickFunc()" tabindex="5"> <input type="button" onclick="onclickFunc()" tabindex="6"> <input type="button" onclick="onclickFunc()" tabindex="7"> </form> </html>
keyenter.js
/* キーダウンイベント処理 */ function getKeyDown(){ /* 特殊キーの制御 */ if(event.keyCode==13){ /* Enter */ if(document.activeElement.type=='button'){ /* Enterを押されたのがbutonnであれば処理を終了する */ return true; /* Ctrlキーを押されていない場合 */ }else if(event.ctrlKey==false){ /* KeyCodeをTab押下に書き換える*/ event.keyCode=9; return true; } } } /* キーダウンイベントをgetKeyDownにハンドリング */ document.onkeydown=getKeyDown;