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)
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.
Comment 2•22 years ago
|
||
> <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
Reporter | ||
Comment 3•22 years ago
|
||
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."
Reporter | ||
Comment 5•22 years ago
|
||
Hi Greg, Thanks for the note. I tried what you suggested and it didn't change anything... :-( --g
Reporter | ||
Comment 6•22 years ago
|
||
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
Comment 10•22 years ago
|
||
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
Comment 11•22 years ago
|
||
'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
Comment 12•22 years ago
|
||
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.
Updated•22 years ago
|
Whiteboard: DIGBug
Updated•22 years ago
|
Priority: -- → P2
Comment 13•22 years ago
|
||
Any relation to bug 44259 or bug 11335? Does this block bug 122479?
Comment 14•22 years ago
|
||
(Not bug 11335; that should be bug 111335.)
Comment 15•21 years ago
|
||
brain, would this block bug 122479 as well? nominating, since bug 184549 is blocked.
Comment 16•21 years ago
|
||
erm, i meant to say: nominating since this might block bug 122479.
Comment 17•21 years ago
|
||
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 ago → 21 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.4final
You need to log in
before you can comment on or make changes to this bug.
Description
•