Last Comment Bug 631165 - Internationalize keycode values which can input characters and its rule should be consistent on all platforms
: Internationalize keycode values which can input characters and its rule shoul...
: intl, meta
Product: Core
Classification: Components
Component: DOM: Events (show other bugs)
: Trunk
: All All
-- normal (vote)
: mozilla15
Assigned To: Masayuki Nakano [:masayuki]
: Andrew Overholt [:overholt]
Depends on: 447757 519972 630810 630813 677252
Blocks: 306585 432951 432953 479942 680830
  Show dependency treegraph
Reported: 2011-02-03 00:23 PST by Masayuki Nakano [:masayuki]
Modified: 2012-05-17 17:37 PDT (History)
6 users (show)
bugzillamozillaorg_serge_20140323: in‑testsuite-
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Masayuki Nakano [:masayuki] 2011-02-03 00:23:35 PST
We know that there are many keyboard layouts in the world. When we compute a keycode for each key which can input a character, we need a clear rule which is useful on all platforms.

On an old DOM3 Events draft gave some hints for us. Now, I think we should use following rules:

1. If the key can input an alphabet or numeric, it is DOM_VK_[A-Z0-9] (See bug 447757).
2. If the key can input a white space, it's DOM_VK_SPACE. (See bug 479942)
3. For the other keys which input ASCII character, they are computed from unshifted character.
4. For the other keys which input non-ASCII character, they are computed from shifted character if the shifted character is an ASCII character.
5. Otherwise, we should use 0.

For using these rules, we need to define more keys for non-letter characters such as ':', '@' and '<' which are not in unshifted position of US keyboard layout because such characters may be inputtable without shift key on some keyboard layouts.

Note that by these rules, the computed keycode will be based on its unshifted character. But if the key is numeric keys of AZERTY, its keycode is computed as NS_VK_[0-9].

By this change, some web applications which are handling keydown event and keyup event might be broken on some keyboard layout. But I think that such application is rare because:

1. It's too difficult for handling non-letter keys for cross platform and cross browser.
2. This change doesn't break the behavior of keypress event. I guess that most web applications which need to handle key event is using keypress event rather than keydown and keyup events.

If you have some suggestions, please comment here.
Comment 1 User image Masayuki Nakano [:masayuki] 2011-02-08 21:26:49 PST
I posted a patch for Linux in bug 447757. And also I posted a patch for Windows in bug 630810.
Comment 2 User image Masayuki Nakano [:masayuki] 2011-08-08 08:28:03 PDT
I posted a patch for cocoa in bug 677252.
Comment 3 User image Masayuki Nakano [:masayuki] 2012-05-17 15:56:54 PDT
keycode reimplementation is now fixed. I'll implement .key and .char ASAP. It must help to fix some bugs.
Comment 4 User image Masayuki Nakano [:masayuki] 2012-05-17 17:37:01 PDT

Note that, a lot of tests are landed actually:

For Windows:
For Mac:

Note You need to log in before you can comment on or make changes to this bug.