Open Bug 126436 Opened 23 years ago Updated 2 years ago

the e.which property of an key event returns the wrong ascii code

Categories

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

defect

Tracking

()

mozilla1.2alpha

People

(Reporter: slukits, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(4 files)

Well, the summary says actually everything. I  put a test case to it for
investigation.
Attached file The test case
Confirming reported behavior on Mozilla trunk 2002021413 WinNT.
For example, the testcase expects 97 as the e.which for 'a'.
I get 65, which is the expected code for 'A'.

Browser, not engine ---> DOM Events.
OS: Linux ---> All.
Assignee: rogerl → joki
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Events
Ever confirmed: true
OS: Linux → All
QA Contact: pschwartau → vladimire
Severity: normal → blocker
I will add a new testcase that demonstrates one case where e.which works.

(1) Basically it's not working for:
  - window.onkeyup=eventHandler;
  - window.onkeydown=evantHandler; 

(2) And it works for:
  - window.onkeypress=eventHandler;

In the second case, e.which have the proper values. 

It's still not the whole story. With the keypress event the escape
and caps-lock keys are not correct returned whereas they are correct
returned with the keydown and the keyup event. The function keys are
not correct returned by all three of them. Or to be more exact: keyup
and keydown return the wrong keys and keypress returns 0.
I don't want to bother you but I wonder if I didn't understand the
event model right or if there is another bug. As I tried to change my
Application to the keypress event I figured out that this event does
not occur if the focus is in a forms selection control. I have in
my application some of them and wrote among other things a
functionality to make the selection controls smarter so that they not
only recognize the first character but all of them if they fit to the
beginning of a option value. And I actually don't want to put to each
selection control a onKeyPress event as this would be a waist of
resources, I think. I have a test case if you need one. But I'm not
sure if this should rather become a new bug therefore I wait for your respond.
And again. When I add the onKeyPress event to my selection controls I get a js
error that e has no properties. E is the variable which should contain the key
code. So I'm at the beginning again :-(.
man is this so uncool -> nsbeta1
Keywords: nsbeta1
Sorry, I don't understand what you mean with this.
I mean that this bug is bad and should be fixed. I have nominated it to be fixed
in the next netscape release. since i am here again, nominate for mozilla 1.0 as
well.
Keywords: mozilla1.0
nsbeta1+ per ADT/Embed triage.

Is there a URL here? IS anyone still using this out in the wild? If yes, pls
renominate.
I think Jaime meant nsbeta1-
Keywords: nsbeta1nsbeta1-
Target Milestone: --- → mozilla1.2
Keywords: testcase
Priority: -- → P3
This testcase the difference between key down (wrong) and key press (ok)
not a blocker.
Severity: blocker → normal
Assignee: joki → events
QA Contact: vladimire → ian
Hardware: PC → All
*** Bug 284703 has been marked as a duplicate of this bug. ***
In Gecko/Win, keydown events only know about scan codes. Only keypress events have had the necessary character code decoding applied.

It's possible that IE behaves differently here and generates duplicate events for keydown and keypress, whereas we generate a "real" keydown.

The W3C appears to be deprecating keypress in favour of keydown, although I've got no idea how we'd implement keyup in that model.
Assignee: events → nobody
QA Contact: ian → events
Bulk priority change, per :mdaly
Priority: P3 → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: