Closed Bug 265961 Opened 20 years ago Closed 20 years ago

"event.keyCode" does not return a proper value, whereas "event.charCode" does. They should be equivalent (?).

Categories

(Toolkit :: Form Manager, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: tom.uijldert, Assigned: bugs)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20040913 Firefox/0.10.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20040913 Firefox/0.10.1 Browse the HTML given below. On entering any keyboard-character, the displayed "keyCode" remains at 0. This should be equivalent to "charCode" (according to documentation anyway...). ---------- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"> <script type="text/javascript"> function CharCheck(e) { document.frm.text.value = "keycode = " + e.keyCode + " charcode = " + e.charCode; } </script> </head> <body> <form method="post" action="http://bladibla.cgi" name="frm"> <table border="0"> <tbody valign="top"> <tr> <td>Text area input: </td> <td><textarea rows="1" cols="60" wrap="soft" onkeypress="CharCheck(event);"></textarea> </tr> <tr> <td>Text area output:</td> <td><textarea rows="1" cols="60" wrap="soft" name="text" onkeypress="CharCheck(event);"></textarea> </td> </tr> </tbody></table> </form> </body></html> Reproducible: Always Steps to Reproduce: 1. Cut&Paste the html given in "Details" into a file "tst.html" (or whatever your preference) 2. Start browsing the document. 3. Enter any keystrokes in the input-form, observe the result. Actual Results: See "Details". Expected Results: Display the same numerical code twice. -
(In reply to comment #0) > Browse the HTML given below. On entering any keyboard-character, the displayed > "keyCode" remains at 0. This should be equivalent to "charCode" (according to > documentation anyway...). You'll probably find http://www.mozilla.org/editor/key-event-spec.html or http://www.brainjar.com/dhtml/events/default4.asp more useful as documentation for Mozilla key events. keypress sets charCode to the actual character produced by one or more keys being pressed, keydown/keyup sets keyCode to a particular key on the keyboard.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.