Closed Bug 148130 Opened 22 years ago Closed 21 years ago

[mac] keydown Event Listeners aren't functioning at all

Categories

(Core :: DOM: Events, defect, P2)

PowerPC
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla1.4final

People

(Reporter: got, Assigned: bryner)

References

()

Details

(Keywords: dom2, testcase, Whiteboard: DIGBug)

Attachments

(2 files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0rc3)
Gecko/20020523
BuildID:    2002052305

Given a Javascript function that is called via the body onload event.  In this
function we register a function to be called in response to "keydown" events:

window.addEventListener( "keydown", handleKeyDown, false );

The registered function (handleKeyDown) is never called.

Reproducible: Always
Steps to Reproduce:
1. <body onload="onLoadInit">
2. Javascript function onLoadInit:
function onLoadInit()
{
    window.addEventListener( "keydown", handleKeyDown, false );
}
3. Javascript function handleKeyDown:
function handleKeyDown( evt )
{
    alert( "handleKeyDown" );
}
4. Click anywhere in the content area of the page and then press any key.  The
handleKeyDown function should be called, but is not.

Actual Results:  The handleKeyDown function is never called.

Expected Results:  The handleKeyDown function should be called when a key is
pressed.
Aren't event handlers restricted to document elements?
> <body onload="onLoadInit">

Um, er, 'onload="onLoadInit()"' ??

With that change, the following works for me.

<html>
<head>
<script>
function handleKeyDown(evt) {
    alert("handleKeyDown");
}
function onLoadInit() {
    window.addEventListener("keydown", handleKeyDown, false);
}
</script>
</head>
<body onload="onLoadInit();">
  Press a key. Win a prize.
</body>
</html>
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Hi John,

Thanks for the comment.  Sorry for the typo in my comments.  If you look, for
example, at the URL that I provided in the initial bug report...that page does
have the correct syntax.

OK, so I tried the example you provided...it does not work!  Could it be a
platform-specific thing?  I'm running the Mac OSX version.

Regards,

--gordon
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Gordon, per my Comment 1, I think the EventTarget Interface (in which the
addEventListener method is implemented) is restricted to Document nodes. Try
setting the listener on "document." rather than "window."
Hi Greg,

Thanks for the note.  I tried what you suggested and it didn't change
anything... :-(

--g
A little more info...

addEventListener for "keyup" and "keypress", for either window or document,
works fine.  Just the "keydown" event is not working.
Confirmed using FizzillaCFM/2002052305 (RC3). keydown isn't working at all,
though keypress and keyup are.

Nothing is being generated on the JavaScript console. Raising Severity and
editing Summary.
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: dom2
Summary: addEventListener/keydown not working → keydown Event Listeners not functioning at all
Keywords: testcase
WFM on Gecko/20020530 Win2k
The testcase I attached listens for keydown and keypress events, which should be
generated in that order. If Mozilla catches the keydown, you'll see an alert,
"keydown event heard!" If not, you'll see an alert, "keypress event heard:
keydown failed."
Summary: keydown Event Listeners not functioning at all → keydown Event Listeners aren't functioning at all
'keydown' works on linux/win32 builds of machv. It fails on machv/OSX, although
it works in a chimera build.
Summary: keydown Event Listeners aren't functioning at all → [mac] keydown Event Listeners aren't functioning at all
Attached file 'Nuther test
I've also seen this problem.  Seems Mac specific.  I've attached my test case
for this, which gets keydown events on all platforms except for
Moz1.1(2002072203) and NS7PR1.
Whiteboard: DIGBug
Priority: -- → P2
Any relation to bug 44259 or bug 11335? Does this block bug 122479?
(Not bug 11335; that should be bug 111335.)
Depends on: 184549
brain, would this block bug 122479 as well? nominating, since bug 184549 is blocked.
Assignee: joki → bryner
Depends on: 122479
Keywords: nsbeta1
erm, i meant to say: nominating since this might block bug 122479.
Blocks: 122479
No longer depends on: 122479
resolving this bug as fixed; both test cases now work for getting all key
events.  I did notice some bugs with the keycode generation for some keys but I
think those are covered in other bugs.  I wish this test case were in the other
bugs! :-)
Status: NEW → RESOLVED
Closed: 22 years ago21 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.4final
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: