Closed
Bug 140846
Opened 24 years ago
Closed 24 years ago
keyPress event handler always recieves 0 in keyCode
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 112379
People
(Reporter: Spy_HunterC64, Assigned: joki)
Details
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.9+)
Gecko/20020406
BuildID: 2002040608
The event passed to the keypress handler has event.keyCode = 0 no matter which
key was pressed. event.which always contains the correct value. In keydown and
keyup handlers keyCode always both contain the correct value. Testcase included
below.
Reproducible: Always
Steps to Reproduce:
1. Load testcase.
2. Click on the paragraph of text to focus the document.
3. Press a key. A dialog will inform you of the value of event.which and
event.keyCode. They should be the same.
Testcase:
<html>
<head>
<script>
function keyPressEvent(event)
{
alert("Key Press event: event.keyCode = " + event.keyCode
+ ", event.which = " + event.which);
}
</script>
</head>
<body id="bodyElement" onKeyPress="keyPressEvent(event)">
<p>
This is a paragraph of text. This is a paragraph of text. <br>
This is a paragraph of text. This is a paragraph of text. <br>
This is a paragraph of text. This is a paragraph of text. <br>
</p>
</body>
</html>
Comment 1•24 years ago
|
||
Duplicate of Event.keyCode does not always return correct value". See in
particular bug 112379, comment 4 which explains exactly how we set
keyCode/charCode on events and why keyCode and which do not match.
*** This bug has been marked as a duplicate of 112379 ***
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
Updated•23 years ago
|
QA Contact: rakeshmishra → trix
Updated•7 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•