Bug 169209 - keyCodes of the keydown and keyup events do not match in Sogou IME
Summary: keyCodes of the keydown and keyup events do not match in Sogou IME
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 10
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 170368 170369 170370
  Show dependency treegraph
 
Reported: 2017-03-06 11:45 PST by charleyroy
Modified: 2019-02-06 09:18 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description charleyroy 2017-03-06 11:45:33 PST
I tested this on:

* Safari Technology Preview Release 23 (Safari 10.2, WebKit 12604.1.5)
* Safari Version 10.0.3 (12602.4.8)

I am using the Sogou IME (http://pinyin.sogou.com/mac/).

I am using this JS fiddle to log events, but any event logger will show this: https://jsfiddle.net/c1g6rahm/2/

In a content editable, press a punctuation character (eg. the key '.' to get '。', ',' to get ',', 'Shift+1' to get '!' - notice they are full width).

Obtained event trace:
1. textInput
2. input
3. keydown - 229 (WIN_IME key)
4. keyup - 188 (in this case I pressed ',')

This is problematic for a number of reasons:
1. There is no compositionstart/compositionupdate/composition end events, which there should be when using keydown WIN_IME
2. The textInput/input events are not between keydown/keyup, which they should be (they are when pressing regular ASCII/latin characters)
3. There is no keypress event fired. For example, Chrome fires a keypress with keycode 65292 for ',' and with keycode 12290 for '。'

The combination of these make it very hard to detect that these specific characters were selected without relying on the contents of the contenteditable. This also diverges from the spec at https://w3c.github.io/uievents/#events-composition-key-events.
Comment 1 Radar WebKit Bug Importer 2017-03-23 09:26:43 PDT
<rdar://problem/31220961>
Comment 2 Beth Dakin 2017-03-31 16:58:05 PDT
Wenson investigated this, and he found 4 separate issues:

1. Composition events are never fired (it looks like Google Chrome 57.0.2987.110 exhibits the same behavior though)
2. Input events precede keydown/keyup
3. The keypress event is never fired
4. The keyCodes of the keydown and keyup events do not match (229 vs. 190 in the case of ‘。’)

Dominic said that if we can fix #3 or #4, that would be most useful. 

So let's repurpose this bug to represent #4, and I will clone it for the other 3 issues.
Comment 4 charleyroy 2017-04-03 07:48:21 PDT
Thanks Beth and Wenson for investigating more! Just wanted to make sure that the fix for 4 would show the correct code for the character (eg. it should show 12290 for '。' and not 190).

Thanks!
Comment 5 Lucas Forschler 2019-02-06 09:18:32 PST
Mass move bugs into the DOM component.