现在的位置: 首页 > 综合 > 正文

使用onkeypress字符按键兼容所有浏览器

2013年01月07日 ⁄ 综合 ⁄ 共 174字 ⁄ 字号 评论关闭
document.onkeypress = function( e ){
	alert( getCharCode( e ) );
};
function getCharCode( e ){
	var e = e || window.event;
	if( typeof e.charCode == "number" ){
		return e.charCode;
	}else{
		return e.keyCode;
	};
};

抱歉!评论已关闭.