js 捕捉键盘事件 兼容ie6

阅读更多


var msg = document.getElementById("msg"),
userAgent = navigator.userAgent,rMsie = /.*(msie) ([\w.]+).*/,
isIE = false;
if(rMsie.exec(userAgent.toLowerCase())!=null)
	isIE = true;

msg.onkeyup = function(event){
	if(isIE)
		event = window.event;
	alert(event.keyCode)
}

你可能感兴趣的:(ie,ie6,keycode,onkeyup)