1
假设我们有这样的代码:event.altKey铬无法正常工作和IE
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var p = 0;
function reset()
{
// some efforts
}
function code(e) {
e = e || window.event;
return(e.keyCode || e.which);
}
window.onload = function(){
document.onkeypress = function(e){
var key = code(e);
if(key == 38 || key == 40)
{}
else if(e.altKey)
{
alert('altkey pressed');
}
else
{
// Another THING!
}
};
};
</script>
</head>
<body style="padding:30px; font-size:30px;font-family: Courier;">
<span onclick="reset();" accesskey="r"></span>
</body>
</html>
在Firefox的伟大工程,但不是在IE浏览器的。
当我将alt
更改为shift
时,它适用于所有浏览器。但正如你可能会注意到,我想用这个快捷键,我觉得这是在Chrome和IE Alt键关键的问题(因为两者都使用Alt键为accesskey
属性,但Firefox使用Alt键 + 移如mentally here)。
那么你们建议我做什么?
keyup对我更好。不管怎样,谢谢。 – UltraDEVV 2014-09-20 19:37:09