This project is archived and is in readonly mode.

#553 ✓invalid
evoL

Event assignes same keycodes for more keys

Reported by evoL | January 13th, 2009 @ 08:32 PM | in 2.0 (closed)

Tested in release 1.2.1 and build 939470f5bec4e4a9cc0bc2cee6c4b7d240e94923 on Firefox 3.0.5, Opera 9.6, Google Chrome 1.0 and Safari 3.2.1.

The keycode is determined in the Event constructor with the following:

var code = event.which || event.keyCode;

One pair of affected pairs of keys is [Del] and [.]. When Del is pressed, the event.keyCode is set to 46. But if the dot is pressed, the event.charCode and event.which are set to 46. So the result is 46 for both keys. An additional check is needed to properly handle such keys.

There are more of these pairs, e.g. the F1 and P, F2 and Q etc.

Edit: Opera 9.6 assigns no charCode. It sets both keyCode and which for Del and dot (and most other keys), so I have no idea how it is possible to determine which was pressed. For the F1, F2 etc. keys only the keyCode is set.

Webkit-based browsers set all three properties for normal keys, but keys like the F1, F2 and Del keys aren't read by the keyPress event.

Testcases: http://justcode.me/keycode.html http://justcode.me/keycode_down....

My testcases for some reason don't work on IE.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages