Possible Issue with keycodes.js

13 views
Skip to first unread message

Ross Boucher

unread,
Dec 1, 2009, 6:49:22 PM12/1/09
to Closure Library Discuss
In looking through the key event code, in an attempt to improve some
of the edge cases in Cappuccino, I've stumbled upon what seems like a
bug to me. On line 228:

if (goog.userAgent.IE &&
!opt_shiftKey &&
(opt_heldKeyCode == goog.events.KeyCodes.CTRL ||
opt_heldKeyCode == goog.events.KeyCodes.ALT)) {
return false;
}

The corresponding comment from the header above the method:

* Additionally, IE6 does not fire keydown or keypress events for
letters when
* the control or alt keys are held down and the shift key is not. IE7
does
* fire keydown in these cases, though, but not keypress.

From what I can see (and in my own reimplementation of this method),
this only works the first time ctrl/alt+somekey is pressed, because
it's relying on opt_heldKeyCode. Instead, it should simply be using
the flags available in the method: opt_ctrlKey and opt_altKey

It would then look like this:

if (goog.userAgent.IE && !opt_shiftKey && (opt_ctrlKey ||
opt_altKey)) {
return false;
}

In my brief test in IE8, this correctly allowed me to repeat ctrl+key
events without having to first repress ctrl.

Erik Arvidsson

unread,
Dec 3, 2009, 11:31:53 PM12/3/09
to closure-lib...@googlegroups.com
You are correct. I'll provide a fix.
--
erik
Reply all
Reply to author
Forward
0 new messages