jQuery keyup event is being fired twice inside a panel

737 views
Skip to first unread message

Rowno

unread,
Dec 1, 2011, 8:45:14 AM12/1/11
to mozilla-labs-jetpack
I have been using jQuery as a content script inside a panel for DOM
manipulation, which has worked fine so far. I'm now trying to make my
addon keyboard accessible by setting a tabindex on my clickable
<div>'s and registering a keyup event so that I can trigger the same
action when the enter key is pressed. However, for some reason the
keyup event is being fired twice for every key press.

I've tried registering the keyup event in a normal web page using the
exact same HTML that is used inside the panel and it works fine (with
the event only being fired once). I've also tried removing all my
other code, making the only content scripts jQuery and a script that
registers the keyup event but it's still firing the event twice.

I'm not sure if this is a bug related to running jQuery as a content
script or a bug related to Jetpack itself, but I'm pretty sure it's
not any of my code causing the problem.

Roland Warmerdam

unread,
Dec 1, 2011, 9:38:45 PM12/1/11
to mozilla-labs-jetpack
I've created a simple test case addon that shows the problem.
testcase.zip

Rowno

unread,
Dec 3, 2011, 2:50:36 AM12/3/11
to mozilla-labs-jetpack
I've tried attaching a keyup event listener using the native
addEventListener method on the DOM node and the event is still firing
twice, so it's definitely a bug in Jetpack and has nothing to do with
jQuery.

Rowno

unread,
Dec 3, 2011, 4:33:58 AM12/3/11
to mozilla-labs-jetpack
I've found a workaround, which is to return false in the jQuery event
handler. It seems like each key event is propagated twice for some
reason.
Reply all
Reply to author
Forward
0 new messages