Closed Bug 634863 Opened 10 years ago Closed 10 years ago

Reading charCode on a non-keydown event throws exeption

Categories

(Core :: General, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 581850

People

(Reporter: terje.rosenlund, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; nb-NO; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; nb-NO; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

Nice to be warned about user mistakes but this one makes it impossible to avoid an exeption in general event-investigating functions

Reproducible: Always

Steps to Reproduce:
1. Run attachment
I guess its obvious but:

Steps to Reproduce:
1. Watch error-console
2. Run attachment

By the way: Exeption warning contains typo in norwegian:

Advarsel: Egenskapen 'charCode' på em keydown-hendelse bør ikke brukes. Verdien er meningsløs.

Should be: ... 'charCode' på EN keydown-hendelse ... (uppercase identifies typo)
By the way II: 

 - When is charCode meaninfull if it's meaningless in keydown-events?

I pressume the answer is never

Could'nt ff simply drop the warning and return event.keyCode instead then?
1)  This is not an exception; it's a warning.  There's a large difference
2)  The warning was removed a few months ago and will no longer appear in
    Gecko 2.  See bug 581850.

> - When is charCode meaninfull if it's meaningless in keydown-events?

In keypress events.  Note that there may be multiple keypresses for a single keydown, or multiple keydowns for a single keypress, and the _character_ generated will depend on all the keys that are pressed. Which is why talking about charCode is meaningless in a keydown event; all we know at that point is what physical key was pressed (keyCode), not what character will result (charCode).
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 581850
> 2)  The warning was removed..

Nice! Could seem like a small issue but having strict warnings enabled when visiting eg. the link below are causes ff to use about 20% cpu just to handle the warnings. Its also very inconvenient having the error-console flooded with warnings when developing pages.

http://www.facebook.com/plugins/like.php?channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df283c241d745296%26origin%3Dhttp%253A%252F%252Fnhi.no%252Ff3167847af4b168%26relation%3Dparent.parent%26transport%3Dpostmessage&href=http%3A%2F%2Fnhi.no%2Fsykdommer%2Fblod%2Fanemier%2Fpernisios-anemi-1087.html&layout=standard&locale=en_US&node_type=link&sdk=joey&show_faces=false&width=500

> In keypress events.

Ops.. have suppressed the existens of the onkepress-event due to browser issues

Pressing eg. ctrl/a in IE9 gives no keyPress-event while ff do
My solution has been to rely on the keyDown event, handling shift, ctrl and alt 
status in combination with keyCode to determine hotkeys. This implies handling multiple events to get what I want and is not ideal but I have'nt found another way to make a cross-browser compatibel handling
> handling shift, ctrl and alt  status in combination with keyCode to determine
> hotkeys.

For what it's worth, that will break with different keyboard layouts....
You need to log in before you can comment on or make changes to this bug.