捕获CTRL +在Firefox中

问题描述:

按键事件我使用这个代码来捕捉键盘按下事件:捕获CTRL +在Firefox中

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

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

然而,在Firefox上,我得到114,换句话说就是r没有CTRL

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

我建议你看看这个由约翰Resig的插上

Here is the link

这将解决您的问题:)

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