jQuery keydown事件 兼容IE和Firefox

<script type=”text/javascript”>

$(document).ready(function() {
$(document).keydown(function(e) {
varkey = (e.keyCode) || (e.which) || (e.charCode);//兼容IE(e.keyCode)和Firefox(e.which)
if (key == “38”){//向上

}
if (key == “40”){//向下

}
});
});
</script>