Javascript Shortcode Area
-----Version 110606-----
 key-test2 

<body onKeyDown="K=event.keyCode-37">
<style type="text/css"><!--tt { font-family: "MS ゴシック"; }--></style><tt id=F>
<script>

var key=new Object();
var keyConst=new Array();
keyConst[38]="up";
keyConst[40]="down";
keyConst[37]="left";
keyConst[39]="right";
keyConst[32]="space";
keyConst[17]="ctrl";
keyConst[16]="shift";
keyConst[18]="alt";

function Keyboard_Init(){var i;for(i in keyConst){key[i]=false;}

document.onkeydown=function(event){
var i;var kc=KK(event);if (kc in keyConst){i=keyConst[kc];key[i]=true;}
return false;};
document.onkeyup=function(event){
var i;var kc=KK(event);if (kc in keyConst){i=keyConst[kc];key[i]=false;}
return false;}
}


function KK(e){if(document.all) return e.keyCode; else if(document.getElementById) return (e.keyCode)? e.keyCode: e.charCode; else if(document.layers) return e.which;}

Keyboard_Init();
K=0;
function Y(){
document.body.innerHTML=key.up;
setTimeout(Y,100)
}
Y();


</script>


使用変数

i
id
innerHTML
K
kc
key
Keyboard_Init -------( Function )
keyConst
KK -------( Function )
onKeyDown
onkeydown
onkeyup
type
Y -------( Function )