KeyboardEvent.key values of some specific keys of Japanese keyboard layout on Windows are different from Firefox
Reported by
dtoybo...@gmail.com,
May 18 2016
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2739.0 Safari/537.36 Example URL: https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html Steps to reproduce the problem: 1. Install Japanese keyboard layout with Japanese IME into your Windows system (from [Add a language] of control panel). 2. Launch Canary and load https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html 3. Activate Japanese IME and press following keys. What is the expected behavior? I think that Firefox's key value mapping is reasonable. So, Chromium should set same value to KeyboardEvent.key. What went wrong? key label VK Canary Firefox 半角/全角 (*1) VK_OEM_AUTO "`" "Hankaku" 半角/全角 (*1) VK_OEM_ENLW "`" "Zenkaku" 漢字 (*2) VK_KANJI "`" "KanjiMode" 英数 (*3) VK_OEM_ATTN "CapsLock" "Alphanumeric" 英数 (*3) VK_OEM_COPY "CapsLock" "Hiragana" ひらがな (*4) VK_OEM_COPY "KanaMode" "Hiragana" カタカナ (*5) VK_OEM_FINISH "KanaMode" "Katakana" ローマ字 (*6) VK_OEM_BACKTAB "KanaMode" "Romaji" *1 半角/全角 is a toggle key between Hankaku and Zenkaku. When you press this key with Japanese IME, typically, key messages are sent with following pairs: VK_OEM_AUTO with WM_KEYUP -> VK_OEM_ENLW with WM_KEYDOWN or VK_OEM_ENLW with WM_KEYUP or VK_OEM_AUTO with WM_KEYDOWN. *2 漢字 is Alt+半角/全角. *3 英数 is a toggle key between Alphanumeric and Hiragana. When you press this key with Japanese IME, typically, key messages are sent with following pairs: VK_OEM_ATTN with WM_KEYDOWN or VK_OEM_COPY with KEYUP -> VK_OEM_ATTN with WM_KEYDOWN. (Note that Shift+英数 is CapsLock in Japanese keyboard layout) *4 ひらがな is press カタカナ\nひらがな key without any modifiers. Might change input mode to Hiragana. *5 カタカナ is press カタカナ\nひらがな key with Shift. Might change input mode to Katakana. *6 ローマ字 is press カタカナ\nひらがな key with Alt. Might toggle input mode between Romaji mode and Kana mode. Does it occur on multiple sites: Yes Is it a problem with a plugin? No Did this work before? N/A Does this work in other browsers? Yes Chrome version: 52.0.2739.0 Channel: dev OS Version: 10.0 Flash Version: Shockwave Flash 22.0 r0 Note that the VK mapping depends on active Japanese IME and state. For example, After pressing 英数 (VK_OEM_ATTN), ひらがな key press causes WM_KEYUP of VK_OEM_ATTN. This means unlocking the previous input mode. Additionally, Firefox maps these virtual key codes to the key values only when active keyboard layout is Japanese because those OEM virtual key code values may be used for different purpose by other keyboard layouts. Mozilla implemented the mapping in this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=865565
,
May 18 2016
Additionally, those keys cause same key value even if I activate non-Japanese keyboard layout. That's really wrong behavior. For example, in en-US locale, KanaMode, KanjiMode, etc are never available. Looks like that these key values are mapped from "code" value (or scancode)?
,
May 18 2016
FYI: And also VK_CONVERT and VK_NONCONVERT are not mapped in non-Japanese keyboard layout but Chrome maps "Convert" key and "NonConvert" key to "Convert" and "NonConvert" too. Chrome should stop this too. KeyboardEvent.key should be computed from virtual key code since it represents the "function" of the pressed key under current condition (depending on keyboard layout, modifier state, OS, etc).
,
May 18 2016
,
May 18 2016
,
May 18 2016
Surprising that cases 4,5,6 don't work as expected; the platform key-map for Windows does determine the behaviour of the layout under different modifiers - sounds like Windows may be generating the same Unicode character regardless of modifiers, and distinguishing the function exclusively via the VKEY code.
,
Jul 11 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9d990a45f12393c2e557d4b33116b5ce1022b403 commit 9d990a45f12393c2e557d4b33116b5ce1022b403 Author: chongz <chongz@chromium.org> Date: Mon Jul 11 20:06:47 2016 [DomKey] Support Japanese (JIS) layout special keys This CL adds mappings for for keys specific to Japanese (JIS) layouts: 1. "半角/全角\n漢字" (DomKey::HANKAKU/ZENKAKU/KANJI_MODE, DomCode::BACKQUOTE, to the left of Digit1) Used to switch between Hankaku, Zenkaku and KanjiMode, may use with Alt. 2. "Caps Lock\n英数" (DomKey::ALPHANUMERIC/HIRAGANA, DomCode::CAPS_LOCK, same location as CapsLock) Used to switch between Alphanumeric and Hiragana. 3. "カタカナ\nひらがな\nローマ字" (DomKey::KATAKANA/HIRAGANA/ROMAJI, DomCode::KANA_MODE, to the left of AltRight) Used to switch between Katakana, Hiragana and Romaji, may use with Alt or Shift (We don't need to handle Convert/NonConvert specially but could simply put them into the generic mapping table. The reason is their VKEYs are unique and clear - VK_CONVERT/VK_NONCONVERT, and the OS won't produce those VKEYs if they are not supported by current layout. e.g. Will produce 0xff on US layout) Since the VKEYs for these keys express their correct meanings, taking into account modifiers and lock states, we can use a static table to map them to DomKey values. See the BUG for how JIS keyboard works and how to produce these values... Note: Sometimes pressing a key will cause 'keyup' events that does not match this key, this is known and actually means we are leaving the previous state. e.g. Press Alphanumeric key first, and then if you hit Hiragana key you will actually get a keyup for Alphanumeric key, which means you are leaving Alphanumeric state. BUG= 612694 Review-Url: https://codereview.chromium.org/2128573002 Cr-Commit-Position: refs/heads/master@{#404715} [modify] https://crrev.com/9d990a45f12393c2e557d4b33116b5ce1022b403/ui/events/keycodes/keyboard_codes_posix.h [modify] https://crrev.com/9d990a45f12393c2e557d4b33116b5ce1022b403/ui/events/keycodes/keyboard_codes_win.h [modify] https://crrev.com/9d990a45f12393c2e557d4b33116b5ce1022b403/ui/events/keycodes/platform_key_map_win.cc [modify] https://crrev.com/9d990a45f12393c2e557d4b33116b5ce1022b403/ui/events/keycodes/platform_key_map_win_unittest.cc
,
Jul 11 2016
|
||||
►
Sign in to add a comment |
||||
Comment 1 by dtoybo...@gmail.com
, May 18 2016