JavaScript "keypress" event listener stops receiving command key events for Cut, Copy, Paste




13 years ago
11 years ago


(Reporter: david, Assigned: jaas)


Mac OS X
Bug Flags:
blocking1.9 -

Firefox Tracking Flags

(Not tracked)



(1 attachment)



13 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: Gecko/20060308 Firefox/
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: Gecko/20060308 Firefox/

A JavaScript event listener for keypress events works correctly at first for command key events Cmd-X, Cmd-C, and Cmd-V. However, after a user picks "Copy" from the Edit menu, the handler no longer receives any keypress events for Cmd-C.

The problem does not go away after refreshing the page, but it does go away after closing and reopening the browser window.

Reproducible: Always

Steps to Reproduce:
1.  Load the attached HTML page.
2.  Select the letter "a" and press Command-C.
3.  Observe JavaScript alert window indicating that the event listener was called.
4.  Select the letter "a" and pick Copy from the Edit menu.
5.  Select the letter "a" and press Command-C.

Actual Results:  
No JavaScript alert window is displayed.

Expected Results:  
JavaScript alert window indicating that the event listener was called.

Note also that until the Copy command is picked from the Edit menu, the Edit menu does *not* flash when pressing Command-C, but after it is picked, it does flash.

Comment 1

13 years ago
Created attachment 220016 [details]
HTML file that reproduces bug 335693

Comment 2

13 years ago
This bug seems related to bug 256954, which has been closed as a dup of 220900.  I don't think this bug is a dup of 220900, though.  I think this bug is specifically OS X related.  And if that's true, then there's a good chance that 256954 is not actually a dup and should be reopened or duped to 335693.


13 years ago
Summary: JavaScript "keypress" event listesner stops receiving command key events for Cut, Copy, Paste → JavaScript "keypress" event listener stops receiving command key events for Cut, Copy, Paste

Comment 3

13 years ago
This is probably related to some of our mac menu bugs. iirc once a menu have been opened it's the menu's shortcuts that takes over.
Assignee: nobody → joshmoz
Component: General → Widget: Mac
Product: Firefox → Core
QA Contact: general → mac
Version: unspecified → Trunk

Comment 4

11 years ago
I don't know if this is related, but when I try and paste text into a javascript-called window (like making a link in wordpress using the easy link creator thing) command-p doesn't work anymore, I can right click, and select paste though.


11 years ago
Flags: blocking1.9?

Comment 5

11 years ago
This is probably a dupe of bug 417108.
Flags: blocking1.9? → blocking1.9+
Priority: -- → P1

Comment 6

11 years ago
Whatever the state of things were when this bug was reported have long since changed. The "listener stops receiving" aspect is no longer true: the page's js listener never receives cmd+c, ever, period.

Testing with the attached example shows that *no* cmd+letter keypresses are received by the listener -- regardless of whether something is bound to them or not. All key combos involving command + a non-printable key (F keys, arrows) DO generate events, unless they're mapped to some OS function. However, in these cases the keyCode value reported is "0", which obviously isn't right. (Values like "63234" are reported in Safari.)

That last bit holds in general: all non-printable except backspace and enter seem to report keyCode=0, regardless of modifiers. (The modifiers themselves seem to be reported correctly.)

Chords involving ctrl (including ones that are bound) are received.

On this test page, Safari does seem to pass the proper events down to the listener on the page in all cases except when the OS catches it (Exposé keys, for instance) and Safari itself doesn't receive the keypress.

How much of this functionality SHOULD there be?


11 years ago
Component: Widget: Mac → Widget: Cocoa
QA Contact: mac → cocoa

Comment 7

11 years ago
Sorry about my comment before, I didn't read the bug closely enough.

I have known about this bug for a long time, it is a limitation that our native menu architecture has. When a native menu item handles a command it eats the event after invoking the action. I have experimented with solving this in the past and we may be able to do it, but the change is really quite invasive and I wouldn't be comfortable taking it this late in the 1.9 cycle. We should make this a priority for Moz 2 though.

The patch called "menus only visually handle key events" on 398514 is part of my attempt at exploring a solution for this issue.
Ever confirmed: true
Flags: blocking1.9+ → blocking1.9-
Priority: P1 → --

Comment 8

11 years ago
Fixed by the final patch on bug 398514.
Last Resolved: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.