Browser URL bar improvement Becks moves down the road
Jan 10

keyCode pains with Firefox on the Mac

Tech Add comments

I have been playing a lot with GreaseMonkey recently, and ran into a bug that was confusing.

I had added a key combo of Control-Return/Enter to do some work. Nothing was happening when I did that combo so I looked to see what was going wrong.

I put in:

window.addEventListener('keydown', function(e) {
alert(e.keyCode);
}, false);

and started keying around.

Hitting enter/return came up with 13. Good.

Control by itself returned 17. Good.

Control (left or right) and the main Return came back with 77 (which is M)

Control (left or right) and the Enter came back with 67 (which is C)

This is all on FF 2.0.1. Safari came back with flying colors (not much help for GreaseMonkey of course).

This means that if I hack it and capture all of the key combos, if someone really does do a Control-M or a Control-C it would ALSO fire off this event.

Has anyone else run into this? To me, it means that I have to choose another modifier key. Time for Shift-Return I guess.

3 Responses to “keyCode pains with Firefox on the Mac”

  1. Chad Burt Says:

    I have a similar problem. I tried your code, as well as document.onkeydown = function(e){alert(e)}

    I cant for the life of me get the modifier keys to trigger key events on their own. Using javascript keyboard events is looking like a minefield to me.

  2. replica handbags Says:

    forefox is not that good..

  3. Replica handbags Says:

    thanks for sharing,generous blogger

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What is the number before 3? (just put in the digit)