2010-01-02 58 views

回答

2

每個按鍵與鍵碼相關:

$(window).bind("keypress", function(e) { 
    var code = (e.keyCode ? e.keyCode : e.which); // which code? 
    alert(String.fromCharCode(code)); // which key, according to the code? 
}); 
+0

酷,非常感謝你。 – Mikkel 2010-01-02 16:15:03

+0

我怎樣才能看到他們是否打字大寫字母? – Mikkel 2010-01-02 16:49:23

+0

通過檢查代碼:小寫'j'是106,而大寫字母'J'是74. – Sampson 2010-01-02 17:07:03