封装键盘事件
//封装键盘事件
//作者:张沈鹏 http://www.cppblog.com/zuroc/
//版本:1.0_06-12-30
/*
用法演示:
var key= new KeyCode(event);
if(key.enter||key.esc)...
*/
//代码
function KeyCode(event){
if(!event)event=window.event;
keyCode = event.keyCode;
this.del=this.enter=this.esc=this.stepY=this.char=false;
switch(keyCode) {
//for space
//for backspace (8) and delete (46)
case 8:case 46:this.del=true;return;
case 13:this.enter=true;return;
case 27:this.esc=true;return;
case 32:this.char=true;return;
case 38:this.stepY=-1;return;
case 40:this.stepY=1;return;
}
if (!( (keyCode < 46) || (keyCode >= 112 && keyCode <= 123)
))
{this.char=true;}
}