<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link type="text/css" href="/themes/hot-sneaks/jquery-ui.css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery.min.js"> </script>
<script>
$(document).ready(function () {
$("#showWin").click(function () {
$(".main-window").css({'left': '200px', 'top': '2%'}).show();
});
$(document).keypress(function(e){
var code = e.keyCode ? e.keyCode : e.which;
if(code == 27 || code == 96) $(".main-window").hide();
});
});
</script>
</head>
<body>
<button id="showWin">Show Window</button>
<div class="main-window ui-widget-content" style="width: 300px; height: 420px; padding: 2px; display: none; position: fixed;">
<div class="ui-widget-header ui-state-active ui-corner-all" style="height: 20px; padding: 2px; text-align: center; font-size: 14pt;">Test Title</div>
<div class=""><a href="#" name="test2">test 2</a></div>
</div>
</body>
</html>
上面的測試網頁
按一下按鈕會顯示一個小視窗
預期是按鍵盤[ESC]會關閉小視窗
在 firefox, ie6 都可以正常用 [ESC] 關閉
但是 XP 下的 google chrom 則對 esc 鍵沒反應耶~

例如我在 keypress 事件裡加一行 alert(code)
在 google chrom 按其他鍵都可以顯示出 code 值
按 esc 則完全沒有任何反應
這是本來就這樣, 還是 google chrom 的 bug??