2012-09-26 54 views
1

按鍵事件我使用這個代碼來捕捉鍵盤按下事件:捕獲CTRL +在Firefox中

$(document.body).keypress(function(e){ 
    console.log("captured: " + e.which); 
    }); 

在Chrome,當用戶按下CTRL + [R,我得到中charCode 18。

然而,在Firefox上,我得到114,換句話說就是r沒有CTRL

如何捕獲Firefox上的CTRL +事件?最好,我想只接收正確的charcode而不使用任何翻譯表。

回答

0

我建議你看看這個由約翰Resig的插上

Here is the link

這將解決您的問題:)

0
$(document).on('keydown', function(e){ 
    console.log("captured: " + e.which); 
});