New issue
Advanced search Search tips

Issue 891501 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 30
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Keyboard map API not returning key sym for Japanese keyboard

Project Member Reported by ftsui@google.com, Oct 2

Issue description

Chrome Version:  69.0.3497.100 (Official Build) (64 bit)
OS: (e.g. Win10, MacOS 10.12, etc...) Windows

What steps will reproduce the problem?
(1) Plug in a Japanese keyboard, change Windows keyboard layout
(2) Run the script:
 navigator.keyboard.getLayoutMap().then(function(map) { console.log(map.size); for(k of map.entries()) { console.log(k); }; })
(3)

What is the expected result?
Expect "Quote" to map to ":"

What happens instead?
"Quote" maps to "'"

Output of script:
Promise {<pending>}
VM174:1 48
VM174:1 (2) ["KeyE", "e"]
VM174:1 (2) ["KeyD", "d"]
VM174:1 (2) ["Minus", "-"]
VM174:1 (2) ["KeyH", "h"]
VM174:1 (2) ["KeyZ", "z"]
VM174:1 (2) ["Equal", "="]
VM174:1 (2) ["KeyN", "n"]
VM174:1 (2) ["KeyP", "p"]
VM174:1 (2) ["BracketRight", "]"]
VM174:1 (2) ["BracketLeft", "["]
VM174:1 (2) ["Digit8", "8"]
VM174:1 (2) ["Digit9", "9"]
VM174:1 (2) ["KeyS", "s"]
VM174:1 (2) ["Semicolon", ";"]
VM174:1 (2) ["Digit5", "5"]
VM174:1 (2) ["KeyQ", "q"]
VM174:1 (2) ["KeyO", "o"]
VM174:1 (2) ["Period", "."]
VM174:1 (2) ["Digit6", "6"]
VM174:1 (2) ["KeyV", "v"]
VM174:1 (2) ["Digit3", "3"]
VM174:1 (2) ["KeyL", "l"]
VM174:1 (2) ["Backquote", "`"]
VM174:1 (2) ["KeyG", "g"]
VM174:1 (2) ["KeyJ", "j"]
VM174:1 (2) ["KeyT", "t"]
VM174:1 (2) ["Quote", "'"]
VM174:1 (2) ["KeyY", "y"]
VM174:1 (2) ["IntlBackslash", "\"]
VM174:1 (2) ["KeyR", "r"]
VM174:1 (2) ["Backslash", "\"]
VM174:1 (2) ["KeyU", "u"]
VM174:1 (2) ["KeyK", "k"]
VM174:1 (2) ["Slash", "/"]
VM174:1 (2) ["KeyF", "f"]
VM174:1 (2) ["KeyI", "i"]
VM174:1 (2) ["KeyX", "x"]
VM174:1 (2) ["KeyA", "a"]
VM174:1 (2) ["Digit2", "2"]
VM174:1 (2) ["Digit7", "7"]
VM174:1 (2) ["KeyM", "m"]
VM174:1 (2) ["Digit4", "4"]
VM174:1 (2) ["KeyW", "w"]
VM174:1 (2) ["Digit1", "1"]
VM174:1 (2) ["Digit0", "0"]
VM174:1 (2) ["KeyB", "b"]
VM174:1 (2) ["KeyC", "c"]
VM174:1 (2) ["Comma", ","]



Please use labels and text to provide additional information.

If this is a regression (i.e., worked before), please consider using the
bisect tool (https://www.chromium.org/developers/bisect-builds-py) to help
us identify the root cause and more rapidly triage the issue.

For graphics-related bugs, please copy/paste the contents of the about:gpu
page at the end of this report.


 
A few pieces to clarify what's going on here:
1. With a Japanese 109 key keyboard connected, I had to set the keyboard layout in the OS to 109 key independent of everything else. Despite this...

2. Windows didn't automatically pick up on the layout differences, and its handling of the layout gets even weirder.

3. It's possible to add a 'Japanese QWERTY' layout for the english language, but this does NOT properly represent the 109 key layout with ' replaced with : - it appears to instead match the US QWERTY layout.

4. All Japanese language input goes through the Microsoft IME, even typing. It does not seem possible to add a 'keyboard' to the list of input devices.

5. With my machine, where a US-QWERTY layout is installed first, then US-DVORAK, using Japanese through the Microsoft IME, Windows decides that the DVORAK layout represents the highest priority; oddly, not only was it installed later, it's not even the most recently used layout.

6. It's possible to set the perceived priority of language entry by moving a language up/down the list of installed language entries; the entry at the top of the list cannot be removed. However, setting Japanese to the highest priority had no impact on the layout received from this API.

7. The ONLY way to get the proper response from this API was to completely remove the English language entry, leaving only the Japanese entry. At this point, the correct value was returned. Further, the response for letter keys was still in ASCII; the kana were not used.
Status: Assigned (was: Untriaged)
Tracking bug b/116829601

Ping.  Any update on this?
Cc: nzolghadr@chromium.org
A few things going on here:

(1) Windows 10 handles the order of the languages in a strange way. You can set the order via the "Language Preferences" option in the Input Method pop-up menu and this usually matches the order returned by the GetKeyboardLayoutList API. But you can also adjust the visual order using the older "Control Panel > Language" and this will override the order shown to the user, but not the API.

The order of this list (UI and API) ignores the currently active input language, so we manually re-order the list to move the active lang to the top.

This is why it's confusing to use the UI to figure out which layout will be used (beyond the currently active one, which we force to the top).

(2) The Japanese layout is technically not ASCII-capable because not all of the standard keys produce printable values.

The Backquote key is normally a printable key, but the Japanese layout uses it for IME functions (half-width/full-width/kanji).  Because of this, it fails the test to ensure that all keys return a printable value. AFAIK, Japanese is the only language that does this.

To fix this to allow the Japanese layout to be considered ASCII-capable, we'd have to special case this key and return a special value.

Status: Started (was: Assigned)
Project Member

Comment 7 by bugdroid1@chromium.org, Nov 17

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7

commit 9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7
Author: Gary Kacmarcik <garykac@chromium.org>
Date: Sat Nov 17 00:20:46 2018

KeyboardMap - Fix Japanese layout

Previously, the Japanese layout was not returned as the highest-prio
ASCII-capable layout because not all of the writing-system-keys produced
printable characters.  Specifically, the Backquote key is used as the
hankaku/zenkaku key to switch between half-width and full-width chars.

This cl fixes that by handling the Japanese/Backquote key as a special
case, and the keyboard map returns a descriptive string.

Bug:  891501 
Change-Id: Ic473700866d711a532d3946be73ff5ec38db580a
Reviewed-on: https://chromium-review.googlesource.com/c/1340970
Commit-Queue: Gary Kacmarcik <garykac@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609042}
[modify] https://crrev.com/9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7/ui/events/keycodes/dom/dom_keyboard_layout.cc
[modify] https://crrev.com/9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7/ui/events/keycodes/dom/dom_keyboard_layout.h
[modify] https://crrev.com/9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc
[modify] https://crrev.com/9987bfb728f2d9d3c2a2b5621c9df202bd3f77c7/ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc

Status: Fixed (was: Started)

Sign in to add a comment