Closed Bug 1293 Opened 26 years ago Closed 26 years ago

e.which doesn't return a value for keydown events

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

x86
Windows 95
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: angus, Assigned: joki)

Details

Event.which should return the key that was pressed; it returns undefined. Here's a test case: <html> <head> <script> function doit(e) { document.getElementById("mytext").value=e.which; } window.onkeydown=doit; </script> </head> <body> <form> <input type=text size=20 id="mytext"> </form> </body> </html> When you press down a key, the value of that key should appear in the text field.
Status: NEW → ASSIGNED
Right, not hooked up yet.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
I think this should be pretty much solved. It's not 100% compatible, though. In 4.0 we sent the ascii value of the character as which. Now we're sending the virtual key code. For A-Z and 0-9 these values match. For the rest theyu pretty much don't. If we decide we need 100% compat here it might make moving forward tougher. I'm going to mark this fixed. When we to full backwards compat decisions and testing we create a new bug if this is insufficient.
Status: RESOLVED → VERIFIED
Technically this works as of the 12.1.98 build on xpviewer. Specifically, the script doesn't return an 'undefined', but returns the keystroke and (for the most part, at least, as Tom notes) the ASCII value in the text box. Marking as verified. Angus, please re-open if necessary per Tom's 11.18.98 comments.
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.