开发者

Shift + / Key combination not getting detected by javascript in Firefox on Mac OSX

This javascript code always returns zero for " Shift + / " key combination on Firefox 3.6.3 on OSX 10.5.8 But it returns the expected value 191 on Chrome on OSX/mac

GetKeyCode = function(e) {
        var code = 0;
        if (!e) {
            e = window.event
        }
     开发者_开发百科   if (e.keyCode) { 
            code = e.keyCode;
        } else if (e.which) { 
            code = e.which;
        }
        return code;
    };

GetKeyCode is getting keydown event from jQuery.

jQuery(document).keydown(function(e) { ...... });

Is there any bug, or am I missing something very simple here? Please help

Thanks in advance. -Parimal Das


This is a bug in Firefox which is specific to Mac OSX:

https://bugzilla.mozilla.org/show_bug.cgi?id=448434

This happens for a few other keys: period, comma and dash when shift is held.

The following page documents this and many other browser variations on key events:

http://unixpapa.com/js/key.html


If it's coming from jQuery, you should be able to use e.which only. In fact, looking for e.keyCode may be causing the problem, since it's not populated if the Shift key is down. See the Mozilla documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜