[iOS] Key code is 0 for many hardware keyboard keys
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2018 19:13:14 +0000 (19:13 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2018 19:13:14 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189604

Reviewed by Wenson Hsieh.

Source/WebCore:

Based off a patch by Jeremy Jones.

Add iOS-specific implementation of windowsKeyCodeForKeyCode() to map an iOS virtual key code to
the corresponding Windows virtual key code. Only hardware keyboard-generated events have a
virtual key code. For software-generated keyboard events we do what we do now and compute the
Windows virtual key code from the character string associated with the event.

When a WebEvent is instantiated with a non-zero iOS virtual key code (keyCode) we now always
convert it to its corresponding Windows virtual key code without considering the specified
charactersIgnoringModifiers character string. Currently we prefer computing the key code from
charactersIgnoringModifiers regardless of whether a non-zero iOS virtual key code was given.
However this causes special keys, including function keys (e.g. F10) to be misidentified because
keyboard layouts in iOS (at least iOS 12) map such special keys to ASCII control characters (e.g.
F10 maps to ASCII control character "data link escape" = 0x10) as opposed to special 16-bit
integral constants as we do on Mac (e.g. F10 maps to NSF10FunctionKey = 0xF70D on Mac). I will
look to fix up the computation of a Windows virtual key code from a char code on iOS in a
subsequent commit(s). For now, computing the Windows virtual key code directly from the iOS
virtual key code specified to the WebEvent constructor avoids the misidentification using
an ANSI US keyboard layout.

* platform/cocoa/KeyEventCocoa.mm:
(WebCore::windowsKeyCodeForKeyCode): Deleted; moved to KeyEventMac.mm as this mapping is specific to Mac.
* platform/ios/KeyEventIOS.mm:
(WebCore::windowsKeyCodeForKeyCode): Added.
* platform/ios/WebEvent.mm:
(-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:keyCode:isTabKey:characterSet:]): Address the NOTE comment and compute the Windows virtual key code from
the iOS virtual key code when we have one. Also inline the value of an unncessary local variable.
(-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:withInputManagerHint:keyCode:isTabKey:]): Ditto.
* platform/mac/KeyEventMac.mm:
(WebCore::windowsKeyCodeForKeyCode): Moved from KeyEventCocoa.mm. Updated code to make use of WTF_ARRAY_LENGTH() instead
of hardcoding the upper bound of the lookup table.

Source/WebKit:

For a hardware keyboard-generated event (an event with a non-nill event._hidEvent) pass
the key code for the event. Otherwise, do what we do now and pass 0 as the event is likely
a software keyboard-generated event.

* Platform/spi/ios/UIKitSPI.h: Add some more SPI.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView handleKeyEvent:]):

LayoutTests:

Update existing test and test result and add a new test to ensure we dispatch DOM keydown
and DOM keyup events dispatched for special keys.

* fast/events/ios/keydown-keyup-in-non-editable-content-expected.txt: Update expected result.
* fast/events/ios/keydown-keyup-in-non-editable-content.html: Remove logic to test arrow keys
as these are tested in test keydown-keyup-special-keys-in-non-editable-element.html. Also
update manual instructions to use <kbd> to format keyboard keys.
* fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236417 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/ios/keydown-keyup-in-non-editable-content-expected.txt
LayoutTests/fast/events/ios/keydown-keyup-in-non-editable-content.html
LayoutTests/fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/KeyEventCocoa.mm
Source/WebCore/platform/ios/KeyEventIOS.mm
Source/WebCore/platform/ios/WebEvent.mm
Source/WebCore/platform/mac/KeyEventMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 12a8828..7bf1e73 100644 (file)
@@ -1,3 +1,19 @@
+2018-09-24  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Key code is 0 for many hardware keyboard keys
+        https://bugs.webkit.org/show_bug.cgi?id=189604
+
+        Reviewed by Wenson Hsieh.
+
+        Update existing test and test result and add a new test to ensure we dispatch DOM keydown
+        and DOM keyup events dispatched for special keys.
+
+        * fast/events/ios/keydown-keyup-in-non-editable-content-expected.txt: Update expected result.
+        * fast/events/ios/keydown-keyup-in-non-editable-content.html: Remove logic to test arrow keys
+        as these are tested in test keydown-keyup-special-keys-in-non-editable-element.html. Also
+        update manual instructions to use <kbd> to format keyboard keys.
+        * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:
+
 2018-09-24  Simon Fraser  <simon.fraser@apple.com>
 
         feMorphology filter in CSS doesn't update when element moves
index 2032f20..4d6272a 100644 (file)
-This tests that DOM keydown and keyup events are dispatched to a non-editable <body> on iOS for hardware key presses. To run this test manually, verify that two messages are emitted when you press the following keys: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -, =, [, ], \, ;, ', ,, ., /, <return>, ↑, ↓, ←, →.
+This tests that DOM keydown and keyup events are dispatched to a non-editable <body> on iOS for hardware key presses of non-special keys. To run this test manually, verify that two messages are emitted when you press the following keys: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -, =, [, ], \, ;, ', ,, ., /.
 
 type: keydown, key: a, code: KeyA, keyIdentifier: U+0041, keyCode: 65, charCode: 0, keyCode: 65, which: 65
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyA, keyIdentifier: Unidentified, keyCode: 65, charCode: 0, keyCode: 65, which: 65
 type: keydown, key: b, code: KeyB, keyIdentifier: U+0042, keyCode: 66, charCode: 0, keyCode: 66, which: 66
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyB, keyIdentifier: Unidentified, keyCode: 66, charCode: 0, keyCode: 66, which: 66
 type: keydown, key: c, code: KeyC, keyIdentifier: U+0043, keyCode: 67, charCode: 0, keyCode: 67, which: 67
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyC, keyIdentifier: Unidentified, keyCode: 67, charCode: 0, keyCode: 67, which: 67
 type: keydown, key: d, code: KeyD, keyIdentifier: U+0044, keyCode: 68, charCode: 0, keyCode: 68, which: 68
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyD, keyIdentifier: Unidentified, keyCode: 68, charCode: 0, keyCode: 68, which: 68
 type: keydown, key: e, code: KeyE, keyIdentifier: U+0045, keyCode: 69, charCode: 0, keyCode: 69, which: 69
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyE, keyIdentifier: Unidentified, keyCode: 69, charCode: 0, keyCode: 69, which: 69
 type: keydown, key: f, code: KeyF, keyIdentifier: U+0046, keyCode: 70, charCode: 0, keyCode: 70, which: 70
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyF, keyIdentifier: Unidentified, keyCode: 70, charCode: 0, keyCode: 70, which: 70
 type: keydown, key: g, code: KeyG, keyIdentifier: U+0047, keyCode: 71, charCode: 0, keyCode: 71, which: 71
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyG, keyIdentifier: Unidentified, keyCode: 71, charCode: 0, keyCode: 71, which: 71
 type: keydown, key: h, code: KeyH, keyIdentifier: U+0048, keyCode: 72, charCode: 0, keyCode: 72, which: 72
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyH, keyIdentifier: Unidentified, keyCode: 72, charCode: 0, keyCode: 72, which: 72
 type: keydown, key: i, code: KeyI, keyIdentifier: U+0049, keyCode: 73, charCode: 0, keyCode: 73, which: 73
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyI, keyIdentifier: Unidentified, keyCode: 73, charCode: 0, keyCode: 73, which: 73
 type: keydown, key: j, code: KeyJ, keyIdentifier: U+004A, keyCode: 74, charCode: 0, keyCode: 74, which: 74
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyJ, keyIdentifier: Unidentified, keyCode: 74, charCode: 0, keyCode: 74, which: 74
 type: keydown, key: k, code: KeyK, keyIdentifier: U+004B, keyCode: 75, charCode: 0, keyCode: 75, which: 75
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyK, keyIdentifier: Unidentified, keyCode: 75, charCode: 0, keyCode: 75, which: 75
 type: keydown, key: l, code: KeyL, keyIdentifier: U+004C, keyCode: 76, charCode: 0, keyCode: 76, which: 76
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyL, keyIdentifier: Unidentified, keyCode: 76, charCode: 0, keyCode: 76, which: 76
 type: keydown, key: m, code: KeyM, keyIdentifier: U+004D, keyCode: 77, charCode: 0, keyCode: 77, which: 77
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyM, keyIdentifier: Unidentified, keyCode: 77, charCode: 0, keyCode: 77, which: 77
 type: keydown, key: n, code: KeyN, keyIdentifier: U+004E, keyCode: 78, charCode: 0, keyCode: 78, which: 78
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyN, keyIdentifier: Unidentified, keyCode: 78, charCode: 0, keyCode: 78, which: 78
 type: keydown, key: o, code: KeyO, keyIdentifier: U+004F, keyCode: 79, charCode: 0, keyCode: 79, which: 79
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyO, keyIdentifier: Unidentified, keyCode: 79, charCode: 0, keyCode: 79, which: 79
 type: keydown, key: p, code: KeyP, keyIdentifier: U+0050, keyCode: 80, charCode: 0, keyCode: 80, which: 80
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyP, keyIdentifier: Unidentified, keyCode: 80, charCode: 0, keyCode: 80, which: 80
 type: keydown, key: q, code: KeyQ, keyIdentifier: U+0051, keyCode: 81, charCode: 0, keyCode: 81, which: 81
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyQ, keyIdentifier: Unidentified, keyCode: 81, charCode: 0, keyCode: 81, which: 81
 type: keydown, key: r, code: KeyR, keyIdentifier: U+0052, keyCode: 82, charCode: 0, keyCode: 82, which: 82
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyR, keyIdentifier: Unidentified, keyCode: 82, charCode: 0, keyCode: 82, which: 82
 type: keydown, key: s, code: KeyS, keyIdentifier: U+0053, keyCode: 83, charCode: 0, keyCode: 83, which: 83
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyS, keyIdentifier: Unidentified, keyCode: 83, charCode: 0, keyCode: 83, which: 83
 type: keydown, key: t, code: KeyT, keyIdentifier: U+0054, keyCode: 84, charCode: 0, keyCode: 84, which: 84
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyT, keyIdentifier: Unidentified, keyCode: 84, charCode: 0, keyCode: 84, which: 84
 type: keydown, key: u, code: KeyU, keyIdentifier: U+0055, keyCode: 85, charCode: 0, keyCode: 85, which: 85
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyU, keyIdentifier: Unidentified, keyCode: 85, charCode: 0, keyCode: 85, which: 85
 type: keydown, key: v, code: KeyV, keyIdentifier: U+0056, keyCode: 86, charCode: 0, keyCode: 86, which: 86
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyV, keyIdentifier: Unidentified, keyCode: 86, charCode: 0, keyCode: 86, which: 86
 type: keydown, key: w, code: KeyW, keyIdentifier: U+0057, keyCode: 87, charCode: 0, keyCode: 87, which: 87
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyW, keyIdentifier: Unidentified, keyCode: 87, charCode: 0, keyCode: 87, which: 87
 type: keydown, key: x, code: KeyX, keyIdentifier: U+0058, keyCode: 88, charCode: 0, keyCode: 88, which: 88
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyX, keyIdentifier: Unidentified, keyCode: 88, charCode: 0, keyCode: 88, which: 88
 type: keydown, key: y, code: KeyY, keyIdentifier: U+0059, keyCode: 89, charCode: 0, keyCode: 89, which: 89
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyY, keyIdentifier: Unidentified, keyCode: 89, charCode: 0, keyCode: 89, which: 89
 type: keydown, key: z, code: KeyZ, keyIdentifier: U+005A, keyCode: 90, charCode: 0, keyCode: 90, which: 90
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: KeyZ, keyIdentifier: Unidentified, keyCode: 90, charCode: 0, keyCode: 90, which: 90
 type: keydown, key: 0, code: Digit0, keyIdentifier: U+0030, keyCode: 48, charCode: 0, keyCode: 48, which: 48
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit0, keyIdentifier: Unidentified, keyCode: 48, charCode: 0, keyCode: 48, which: 48
 type: keydown, key: 1, code: Digit1, keyIdentifier: U+0031, keyCode: 49, charCode: 0, keyCode: 49, which: 49
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit1, keyIdentifier: Unidentified, keyCode: 49, charCode: 0, keyCode: 49, which: 49
 type: keydown, key: 2, code: Digit2, keyIdentifier: U+0032, keyCode: 50, charCode: 0, keyCode: 50, which: 50
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit2, keyIdentifier: Unidentified, keyCode: 50, charCode: 0, keyCode: 50, which: 50
 type: keydown, key: 3, code: Digit3, keyIdentifier: U+0033, keyCode: 51, charCode: 0, keyCode: 51, which: 51
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit3, keyIdentifier: Unidentified, keyCode: 51, charCode: 0, keyCode: 51, which: 51
 type: keydown, key: 4, code: Digit4, keyIdentifier: U+0034, keyCode: 52, charCode: 0, keyCode: 52, which: 52
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit4, keyIdentifier: Unidentified, keyCode: 52, charCode: 0, keyCode: 52, which: 52
 type: keydown, key: 5, code: Digit5, keyIdentifier: U+0035, keyCode: 53, charCode: 0, keyCode: 53, which: 53
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit5, keyIdentifier: Unidentified, keyCode: 53, charCode: 0, keyCode: 53, which: 53
 type: keydown, key: 6, code: Digit6, keyIdentifier: U+0036, keyCode: 54, charCode: 0, keyCode: 54, which: 54
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit6, keyIdentifier: Unidentified, keyCode: 54, charCode: 0, keyCode: 54, which: 54
 type: keydown, key: 7, code: Digit7, keyIdentifier: U+0037, keyCode: 55, charCode: 0, keyCode: 55, which: 55
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit7, keyIdentifier: Unidentified, keyCode: 55, charCode: 0, keyCode: 55, which: 55
 type: keydown, key: 8, code: Digit8, keyIdentifier: U+0038, keyCode: 56, charCode: 0, keyCode: 56, which: 56
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit8, keyIdentifier: Unidentified, keyCode: 56, charCode: 0, keyCode: 56, which: 56
 type: keydown, key: 9, code: Digit9, keyIdentifier: U+0039, keyCode: 57, charCode: 0, keyCode: 57, which: 57
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Digit9, keyIdentifier: Unidentified, keyCode: 57, charCode: 0, keyCode: 57, which: 57
 type: keydown, key: -, code: Minus, keyIdentifier: U+002D, keyCode: 189, charCode: 0, keyCode: 189, which: 189
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Minus, keyIdentifier: Unidentified, keyCode: 189, charCode: 0, keyCode: 189, which: 189
 type: keydown, key: =, code: Equal, keyIdentifier: U+003D, keyCode: 187, charCode: 0, keyCode: 187, which: 187
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Equal, keyIdentifier: Unidentified, keyCode: 187, charCode: 0, keyCode: 187, which: 187
 type: keydown, key: [, code: BracketLeft, keyIdentifier: U+005B, keyCode: 219, charCode: 0, keyCode: 219, which: 219
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: BracketLeft, keyIdentifier: Unidentified, keyCode: 219, charCode: 0, keyCode: 219, which: 219
 type: keydown, key: ], code: BracketRight, keyIdentifier: U+005D, keyCode: 221, charCode: 0, keyCode: 221, which: 221
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: BracketRight, keyIdentifier: Unidentified, keyCode: 221, charCode: 0, keyCode: 221, which: 221
 type: keydown, key: \, code: Backslash, keyIdentifier: U+005C, keyCode: 220, charCode: 0, keyCode: 220, which: 220
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Backslash, keyIdentifier: Unidentified, keyCode: 220, charCode: 0, keyCode: 220, which: 220
 type: keydown, key: ;, code: Semicolon, keyIdentifier: U+003B, keyCode: 186, charCode: 0, keyCode: 186, which: 186
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Semicolon, keyIdentifier: Unidentified, keyCode: 186, charCode: 0, keyCode: 186, which: 186
 type: keydown, key: ', code: Quote, keyIdentifier: U+0027, keyCode: 222, charCode: 0, keyCode: 222, which: 222
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Quote, keyIdentifier: Unidentified, keyCode: 222, charCode: 0, keyCode: 222, which: 222
 type: keydown, key: ,, code: Comma, keyIdentifier: U+002C, keyCode: 188, charCode: 0, keyCode: 188, which: 188
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Comma, keyIdentifier: Unidentified, keyCode: 188, charCode: 0, keyCode: 188, which: 188
 type: keydown, key: ., code: Period, keyIdentifier: U+002E, keyCode: 190, charCode: 0, keyCode: 190, which: 190
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Period, keyIdentifier: Unidentified, keyCode: 190, charCode: 0, keyCode: 190, which: 190
 type: keydown, key: /, code: Slash, keyIdentifier: U+002F, keyCode: 191, charCode: 0, keyCode: 191, which: 191
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Enter, code: Enter, keyIdentifier: Enter, keyCode: 13, charCode: 0, keyCode: 13, which: 13
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: ArrowUp, code: ArrowUp, keyIdentifier: Up, keyCode: 38, charCode: 0, keyCode: 38, which: 38
-type: keyup, key: ArrowUp, code: ArrowUp, keyIdentifier: Up, keyCode: 38, charCode: 0, keyCode: 38, which: 38
-type: keyup, key: ArrowDown, code: ArrowDown, keyIdentifier: Down, keyCode: 40, charCode: 0, keyCode: 40, which: 40
-type: keydown, key: ArrowLeft, code: ArrowLeft, keyIdentifier: Left, keyCode: 37, charCode: 0, keyCode: 37, which: 37
-type: keyup, key: ArrowLeft, code: ArrowLeft, keyIdentifier: Left, keyCode: 37, charCode: 0, keyCode: 37, which: 37
-type: keyup, key: ArrowRight, code: ArrowRight, keyIdentifier: Right, keyCode: 39, charCode: 0, keyCode: 39, which: 39
+type: keyup, key: Dead, code: Slash, keyIdentifier: Unidentified, keyCode: 191, charCode: 0, keyCode: 191, which: 191
 
index 59c00eb..4bdcb75 100644 (file)
@@ -11,13 +11,11 @@ if (window.testRunner) {
 </script>
 </head>
 <body onkeydown="handleKeyDown(event)" onkeyup="handleKeyUp(event)">
-<p>This tests that DOM keydown and keyup events are dispatched to a non-editable &lt;body&gt; on iOS for hardware key presses. To run this test manually, verify that two messages are emitted when you press the following keys: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -, =, [, ], \, ;, ', ,, ., /, &lt;return&gt;, &#x2191;, &#x2193;, &#x2190;, &#x2192;.</p>
+<p>This tests that DOM keydown and keyup events are dispatched to a non-editable &lt;body&gt; on iOS for hardware key presses of non-special keys. To run this test manually, verify that two messages are emitted when you press the following keys: <kbd>a</kbd>, <kbd>b</kbd>, <kbd>c</kbd>, <kbd>d</kbd>, <kbd>e</kbd>, <kbd>f</kbd>, <kbd>g</kbd>, <kbd>h</kbd>, <kbd>i</kbd>, <kbd>j</kbd>, <kbd>k</kbd>, <kbd>l</kbd>, <kbd>m</kbd>, <kbd>n</kbd>, <kbd>o</kbd>, <kbd>p</kbd>, <kbd>q</kbd>, <kbd>r</kbd>, <kbd>s</kbd>, <kbd>t</kbd>, <kbd>u</kbd>, <kbd>v</kbd>, <kbd>w</kbd>, <kbd>x</kbd>, <kbd>y</kbd>, <kbd>z</kbd>, <kbd>0</kbd>, <kbd>1</kbd>, <kbd>2</kbd>, <kbd>3</kbd>, <kbd>4</kbd>, <kbd>5</kbd>, <kbd>6</kbd>, <kbd>7</kbd>, <kbd>8</kbd>, <kbd>9</kbd>, <kbd>-</kbd>, <kbd>=</kbd>, <kbd>[</kbd>, <kbd>]</kbd>, <kbd>\</kbd>, <kbd>;</kbd>, <kbd>'</kbd>, <kbd>,</kbd>, <kbd>.</kbd>, <kbd>/</kbd>.</p>
 <pre id="console"></pre>
 <script>
-const asciiCharacters = "abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;',./\r".split("");
-const specialKeys = ["upArrow", "downArrow", "leftArrow", "rightArrow"];
-
-var remainingKeysToPress = asciiCharacters.concat(specialKeys);
+const asciiCharacters = "abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;',./".split("");
+var remainingKeysToPress = asciiCharacters;
 
 async function nextKeyPress()
 {
index 45e9043..333f055 100644 (file)
@@ -7,72 +7,70 @@ type: keydown, key: ArrowLeft, code: ArrowLeft, keyIdentifier: Left, keyCode: 37
 type: keyup, key: ArrowLeft, code: ArrowLeft, keyIdentifier: Left, keyCode: 37, charCode: 0, keyCode: 37, which: 37
 type: keyup, key: ArrowRight, code: ArrowRight, keyIdentifier: Right, keyCode: 39, charCode: 0, keyCode: 39, which: 39
 type: keydown, key: Backspace, code: Backspace, keyIdentifier: U+0008, keyCode: 8, charCode: 0, keyCode: 8, which: 8
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \ 4, code: Unidentified, keyIdentifier: U+0004, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Backspace, keyIdentifier: Unidentified, keyCode: 8, charCode: 0, keyCode: 8, which: 8
+type: keydown, key: \ 4, code: End, keyIdentifier: U+0004, keyCode: 35, charCode: 0, keyCode: 35, which: 35
+type: keyup, key: Dead, code: End, keyIdentifier: Unidentified, keyCode: 35, charCode: 0, keyCode: 35, which: 35
 type: keydown, key: Enter, code: Enter, keyIdentifier: Enter, keyCode: 13, charCode: 0, keyCode: 13, which: 13
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: UIKeyInputEscape, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: UIKeyInputEscape, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \ 1, code: Unidentified, keyIdentifier: U+0001, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: UIKeyInputPageDown, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: UIKeyInputPageDown, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: UIKeyInputPageUp, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Enter, keyIdentifier: Unidentified, keyCode: 13, charCode: 0, keyCode: 13, which: 13
+type: keydown, key: UIKeyInputEscape, code: Escape, keyIdentifier: Unidentified, keyCode: 27, charCode: 0, keyCode: 27, which: 27
+type: keyup, key: UIKeyInputEscape, code: Escape, keyIdentifier: Unidentified, keyCode: 27, charCode: 0, keyCode: 27, which: 27
+type: keydown, key: \ 1, code: Home, keyIdentifier: U+0001, keyCode: 36, charCode: 0, keyCode: 36, which: 36
+type: keyup, key: Dead, code: Home, keyIdentifier: Unidentified, keyCode: 36, charCode: 0, keyCode: 36, which: 36
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 45, charCode: 0, keyCode: 45, which: 45
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 45, charCode: 0, keyCode: 45, which: 45
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
+type: keydown, key: Dead, code: MetaLeft, keyIdentifier: Unidentified, keyCode: 91, charCode: 0, keyCode: 91, which: 91
+type: keyup, key: Dead, code: MetaLeft, keyIdentifier: Unidentified, keyCode: 91, charCode: 0, keyCode: 91, which: 91
+type: keydown, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
+type: keyup, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
+type: keydown, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
+type: keyup, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
+type: keydown, key: UIKeyInputPageDown, code: PageDown, keyIdentifier: Unidentified, keyCode: 34, charCode: 0, keyCode: 34, which: 34
+type: keyup, key: UIKeyInputPageDown, code: PageDown, keyIdentifier: Unidentified, keyCode: 34, charCode: 0, keyCode: 34, which: 34
+type: keyup, key: UIKeyInputPageUp, code: PageUp, keyIdentifier: Unidentified, keyCode: 33, charCode: 0, keyCode: 33, which: 33
 type: keydown, key: Enter, code: Enter, keyIdentifier: Enter, keyCode: 13, charCode: 0, keyCode: 13, which: 13
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \10, code: Unidentified, keyIdentifier: U+0010, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: \ 5, code: Unidentified, keyIdentifier: U+0005, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
-type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keyup, key: Dead, code: Enter, keyIdentifier: Unidentified, keyCode: 13, charCode: 0, keyCode: 13, which: 13
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 93, charCode: 0, keyCode: 93, which: 93
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 93, charCode: 0, keyCode: 93, which: 93
+type: keydown, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
+type: keyup, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
+type: keydown, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
+type: keyup, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
+type: keydown, key: \10, code: F1, keyIdentifier: U+0010, keyCode: 112, charCode: 0, keyCode: 112, which: 112
+type: keyup, key: Dead, code: F1, keyIdentifier: Unidentified, keyCode: 112, charCode: 0, keyCode: 112, which: 112
+type: keydown, key: \10, code: F2, keyIdentifier: U+0010, keyCode: 113, charCode: 0, keyCode: 113, which: 113
+type: keyup, key: Dead, code: F2, keyIdentifier: Unidentified, keyCode: 113, charCode: 0, keyCode: 113, which: 113
+type: keydown, key: \10, code: F3, keyIdentifier: U+0010, keyCode: 114, charCode: 0, keyCode: 114, which: 114
+type: keyup, key: Dead, code: F3, keyIdentifier: Unidentified, keyCode: 114, charCode: 0, keyCode: 114, which: 114
+type: keydown, key: \10, code: F4, keyIdentifier: U+0010, keyCode: 115, charCode: 0, keyCode: 115, which: 115
+type: keyup, key: Dead, code: F4, keyIdentifier: Unidentified, keyCode: 115, charCode: 0, keyCode: 115, which: 115
+type: keydown, key: \10, code: F5, keyIdentifier: U+0010, keyCode: 116, charCode: 0, keyCode: 116, which: 116
+type: keyup, key: Dead, code: F5, keyIdentifier: Unidentified, keyCode: 116, charCode: 0, keyCode: 116, which: 116
+type: keydown, key: \10, code: F6, keyIdentifier: U+0010, keyCode: 117, charCode: 0, keyCode: 117, which: 117
+type: keyup, key: Dead, code: F6, keyIdentifier: Unidentified, keyCode: 117, charCode: 0, keyCode: 117, which: 117
+type: keydown, key: \10, code: F7, keyIdentifier: U+0010, keyCode: 118, charCode: 0, keyCode: 118, which: 118
+type: keyup, key: Dead, code: F7, keyIdentifier: Unidentified, keyCode: 118, charCode: 0, keyCode: 118, which: 118
+type: keydown, key: \10, code: F8, keyIdentifier: U+0010, keyCode: 119, charCode: 0, keyCode: 119, which: 119
+type: keyup, key: Dead, code: F8, keyIdentifier: Unidentified, keyCode: 119, charCode: 0, keyCode: 119, which: 119
+type: keydown, key: \10, code: F9, keyIdentifier: U+0010, keyCode: 120, charCode: 0, keyCode: 120, which: 120
+type: keyup, key: Dead, code: F9, keyIdentifier: Unidentified, keyCode: 120, charCode: 0, keyCode: 120, which: 120
+type: keydown, key: \10, code: F10, keyIdentifier: U+0010, keyCode: 121, charCode: 0, keyCode: 121, which: 121
+type: keyup, key: Dead, code: F10, keyIdentifier: Unidentified, keyCode: 121, charCode: 0, keyCode: 121, which: 121
+type: keydown, key: \10, code: F11, keyIdentifier: U+0010, keyCode: 122, charCode: 0, keyCode: 122, which: 122
+type: keyup, key: Dead, code: F11, keyIdentifier: Unidentified, keyCode: 122, charCode: 0, keyCode: 122, which: 122
+type: keydown, key: \10, code: F12, keyIdentifier: U+0010, keyCode: 123, charCode: 0, keyCode: 123, which: 123
+type: keyup, key: Dead, code: F12, keyIdentifier: Unidentified, keyCode: 123, charCode: 0, keyCode: 123, which: 123
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 43, charCode: 0, keyCode: 43, which: 43
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 43, charCode: 0, keyCode: 43, which: 43
+type: keydown, key: \ 5, code: Unidentified, keyIdentifier: U+0005, keyCode: 45, charCode: 0, keyCode: 45, which: 45
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 45, charCode: 0, keyCode: 45, which: 45
 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 41, charCode: 0, keyCode: 41, which: 41
+type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 41, charCode: 0, keyCode: 41, which: 41
 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
@@ -87,4 +85,6 @@ type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCo
 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+type: keydown, key: Dead, code: AudioVolumeMute, keyIdentifier: Unidentified, keyCode: 173, charCode: 0, keyCode: 173, which: 173
+type: keyup, key: Dead, code: AudioVolumeMute, keyIdentifier: Unidentified, keyCode: 173, charCode: 0, keyCode: 173, which: 173
 
index 7df80d8..7624df2 100644 (file)
@@ -1,3 +1,42 @@
+2018-09-24  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Key code is 0 for many hardware keyboard keys
+        https://bugs.webkit.org/show_bug.cgi?id=189604
+
+        Reviewed by Wenson Hsieh.
+
+        Based off a patch by Jeremy Jones.
+
+        Add iOS-specific implementation of windowsKeyCodeForKeyCode() to map an iOS virtual key code to
+        the corresponding Windows virtual key code. Only hardware keyboard-generated events have a
+        virtual key code. For software-generated keyboard events we do what we do now and compute the
+        Windows virtual key code from the character string associated with the event.
+
+        When a WebEvent is instantiated with a non-zero iOS virtual key code (keyCode) we now always
+        convert it to its corresponding Windows virtual key code without considering the specified
+        charactersIgnoringModifiers character string. Currently we prefer computing the key code from
+        charactersIgnoringModifiers regardless of whether a non-zero iOS virtual key code was given.
+        However this causes special keys, including function keys (e.g. F10) to be misidentified because
+        keyboard layouts in iOS (at least iOS 12) map such special keys to ASCII control characters (e.g.
+        F10 maps to ASCII control character "data link escape" = 0x10) as opposed to special 16-bit
+        integral constants as we do on Mac (e.g. F10 maps to NSF10FunctionKey = 0xF70D on Mac). I will
+        look to fix up the computation of a Windows virtual key code from a char code on iOS in a
+        subsequent commit(s). For now, computing the Windows virtual key code directly from the iOS
+        virtual key code specified to the WebEvent constructor avoids the misidentification using
+        an ANSI US keyboard layout.
+
+        * platform/cocoa/KeyEventCocoa.mm:
+        (WebCore::windowsKeyCodeForKeyCode): Deleted; moved to KeyEventMac.mm as this mapping is specific to Mac.
+        * platform/ios/KeyEventIOS.mm:
+        (WebCore::windowsKeyCodeForKeyCode): Added.
+        * platform/ios/WebEvent.mm:
+        (-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:keyCode:isTabKey:characterSet:]): Address the NOTE comment and compute the Windows virtual key code from
+        the iOS virtual key code when we have one. Also inline the value of an unncessary local variable.
+        (-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:withInputManagerHint:keyCode:isTabKey:]): Ditto.
+        * platform/mac/KeyEventMac.mm:
+        (WebCore::windowsKeyCodeForKeyCode): Moved from KeyEventCocoa.mm. Updated code to make use of WTF_ARRAY_LENGTH() instead
+        of hardcoding the upper bound of the lookup table.
+
 2018-09-24  Simon Fraser  <simon.fraser@apple.com>
 
         feMorphology filter in CSS doesn't update when element moves
index a7821f7..354119c 100644 (file)
@@ -484,145 +484,6 @@ String keyIdentifierForCharCode(unichar charCode)
     }
 }
 
-int windowsKeyCodeForKeyCode(uint16_t keyCode)
-{
-    static const int windowsKeyCode[] = {
-        /* 0 */ VK_A,
-        /* 1 */ VK_S,
-        /* 2 */ VK_D,
-        /* 3 */ VK_F,
-        /* 4 */ VK_H,
-        /* 5 */ VK_G,
-        /* 6 */ VK_Z,
-        /* 7 */ VK_X,
-        /* 8 */ VK_C,
-        /* 9 */ VK_V,
-        /* 0x0A */ VK_OEM_3, // "Section" - key to the left from 1 (ISO Keyboard Only)
-        /* 0x0B */ VK_B,
-        /* 0x0C */ VK_Q,
-        /* 0x0D */ VK_W,
-        /* 0x0E */ VK_E,
-        /* 0x0F */ VK_R,
-        /* 0x10 */ VK_Y,
-        /* 0x11 */ VK_T,
-        /* 0x12 */ VK_1,
-        /* 0x13 */ VK_2,
-        /* 0x14 */ VK_3,
-        /* 0x15 */ VK_4,
-        /* 0x16 */ VK_6,
-        /* 0x17 */ VK_5,
-        /* 0x18 */ VK_OEM_PLUS, // =+
-        /* 0x19 */ VK_9,
-        /* 0x1A */ VK_7,
-        /* 0x1B */ VK_OEM_MINUS, // -_
-        /* 0x1C */ VK_8,
-        /* 0x1D */ VK_0,
-        /* 0x1E */ VK_OEM_6, // ]}
-        /* 0x1F */ VK_O,
-        /* 0x20 */ VK_U,
-        /* 0x21 */ VK_OEM_4, // {[
-        /* 0x22 */ VK_I,
-        /* 0x23 */ VK_P,
-        /* 0x24 */ VK_RETURN, // Return
-        /* 0x25 */ VK_L,
-        /* 0x26 */ VK_J,
-        /* 0x27 */ VK_OEM_7, // '"
-        /* 0x28 */ VK_K,
-        /* 0x29 */ VK_OEM_1, // ;:
-        /* 0x2A */ VK_OEM_5, // \|
-        /* 0x2B */ VK_OEM_COMMA, // ,<
-        /* 0x2C */ VK_OEM_2, // /?
-        /* 0x2D */ VK_N,
-        /* 0x2E */ VK_M,
-        /* 0x2F */ VK_OEM_PERIOD, // .>
-        /* 0x30 */ VK_TAB,
-        /* 0x31 */ VK_SPACE,
-        /* 0x32 */ VK_OEM_3, // `~
-        /* 0x33 */ VK_BACK, // Backspace
-        /* 0x34 */ 0, // n/a
-        /* 0x35 */ VK_ESCAPE,
-        /* 0x36 */ VK_APPS, // Right Command
-        /* 0x37 */ VK_LWIN, // Left Command
-        /* 0x38 */ VK_LSHIFT, // Left Shift
-        /* 0x39 */ VK_CAPITAL, // Caps Lock
-        /* 0x3A */ VK_LMENU, // Left Option
-        /* 0x3B */ VK_LCONTROL, // Left Ctrl
-        /* 0x3C */ VK_RSHIFT, // Right Shift
-        /* 0x3D */ VK_RMENU, // Right Option
-        /* 0x3E */ VK_RCONTROL, // Right Ctrl
-        /* 0x3F */ 0, // fn
-        /* 0x40 */ VK_F17,
-        /* 0x41 */ VK_DECIMAL, // Num Pad .
-        /* 0x42 */ 0, // n/a
-        /* 0x43 */ VK_MULTIPLY, // Num Pad *
-        /* 0x44 */ 0, // n/a
-        /* 0x45 */ VK_ADD, // Num Pad +
-        /* 0x46 */ 0, // n/a
-        /* 0x47 */ VK_CLEAR, // Num Pad Clear
-        /* 0x48 */ VK_VOLUME_UP,
-        /* 0x49 */ VK_VOLUME_DOWN,
-        /* 0x4A */ VK_VOLUME_MUTE,
-        /* 0x4B */ VK_DIVIDE, // Num Pad /
-        /* 0x4C */ VK_RETURN, // Num Pad Enter
-        /* 0x4D */ 0, // n/a
-        /* 0x4E */ VK_SUBTRACT, // Num Pad -
-        /* 0x4F */ VK_F18,
-        /* 0x50 */ VK_F19,
-        /* 0x51 */ VK_OEM_PLUS, // Num Pad =. There is no such key on common PC keyboards, mapping to normal "+=".
-        /* 0x52 */ VK_NUMPAD0,
-        /* 0x53 */ VK_NUMPAD1,
-        /* 0x54 */ VK_NUMPAD2,
-        /* 0x55 */ VK_NUMPAD3,
-        /* 0x56 */ VK_NUMPAD4,
-        /* 0x57 */ VK_NUMPAD5,
-        /* 0x58 */ VK_NUMPAD6,
-        /* 0x59 */ VK_NUMPAD7,
-        /* 0x5A */ VK_F20,
-        /* 0x5B */ VK_NUMPAD8,
-        /* 0x5C */ VK_NUMPAD9,
-        /* 0x5D */ 0, // Yen (JIS Keyboard Only)
-        /* 0x5E */ 0, // Underscore (JIS Keyboard Only)
-        /* 0x5F */ 0, // KeypadComma (JIS Keyboard Only)
-        /* 0x60 */ VK_F5,
-        /* 0x61 */ VK_F6,
-        /* 0x62 */ VK_F7,
-        /* 0x63 */ VK_F3,
-        /* 0x64 */ VK_F8,
-        /* 0x65 */ VK_F9,
-        /* 0x66 */ 0, // Eisu (JIS Keyboard Only)
-        /* 0x67 */ VK_F11,
-        /* 0x68 */ 0, // Kana (JIS Keyboard Only)
-        /* 0x69 */ VK_F13,
-        /* 0x6A */ VK_F16,
-        /* 0x6B */ VK_F14,
-        /* 0x6C */ 0, // n/a
-        /* 0x6D */ VK_F10,
-        /* 0x6E */ 0, // n/a (Windows95 key?)
-        /* 0x6F */ VK_F12,
-        /* 0x70 */ 0, // n/a
-        /* 0x71 */ VK_F15,
-        /* 0x72 */ VK_INSERT, // Help
-        /* 0x73 */ VK_HOME, // Home
-        /* 0x74 */ VK_PRIOR, // Page Up
-        /* 0x75 */ VK_DELETE, // Forward Delete
-        /* 0x76 */ VK_F4,
-        /* 0x77 */ VK_END, // End
-        /* 0x78 */ VK_F2,
-        /* 0x79 */ VK_NEXT, // Page Down
-        /* 0x7A */ VK_F1,
-        /* 0x7B */ VK_LEFT, // Left Arrow
-        /* 0x7C */ VK_RIGHT, // Right Arrow
-        /* 0x7D */ VK_DOWN, // Down Arrow
-        /* 0x7E */ VK_UP, // Up Arrow
-        /* 0x7F */ 0 // n/a
-    };
-
-    if (keyCode >= 0x80)
-        return 0;
-
-     return windowsKeyCode[keyCode];
-}
-
 int windowsKeyCodeForCharCode(unichar charCode)
 {
     switch (charCode) {
index c5b291b..304e9f7 100644 (file)
 
 #if PLATFORM(IOS)
 
+#import "KeyEventCocoa.h"
 #import "NotImplemented.h"
+#import "WindowsKeyboardCodes.h"
+#import <pal/spi/cocoa/IOKitSPI.h>
 
 using namespace WTF;
 
 namespace WebCore {
 
+int windowsKeyCodeForKeyCode(uint16_t keyCode)
+{
+    static const int windowsKeyCode[] = {
+        /* 0 */ 0, // n/a
+        /* 1 */ 0, // n/a
+        /* 2 */ 0, // n/a
+        /* 3 */ 0, // n/a
+        /* 4 */ VK_A,
+        /* 5 */ VK_B,
+        /* 6 */ VK_C,
+        /* 7 */ VK_D,
+        /* 8 */ VK_E,
+        /* 9 */ VK_F,
+        /* 0x0A */ VK_G,
+        /* 0x0B */ VK_H,
+        /* 0x0C */ VK_I,
+        /* 0x0D */ VK_J,
+        /* 0x0E */ VK_K,
+        /* 0x0F */ VK_L,
+        /* 0x10 */ VK_M,
+        /* 0x11 */ VK_N,
+        /* 0x12 */ VK_O,
+        /* 0x13 */ VK_P,
+        /* 0x14 */ VK_Q,
+        /* 0x15 */ VK_R,
+        /* 0x16 */ VK_S,
+        /* 0x17 */ VK_T,
+        /* 0x18 */ VK_U,
+        /* 0x19 */ VK_V,
+        /* 0x1A */ VK_W,
+        /* 0x1B */ VK_X,
+        /* 0x1C */ VK_Y,
+        /* 0x1D */ VK_Z,
+        /* 0x1E */ VK_1,
+        /* 0x1F */ VK_2,
+        /* 0x20 */ VK_3,
+        /* 0x21 */ VK_4,
+        /* 0x22 */ VK_5,
+        /* 0x23 */ VK_6,
+        /* 0x24 */ VK_7,
+        /* 0x25 */ VK_8,
+        /* 0x26 */ VK_9,
+        /* 0x27 */ VK_0,
+        /* 0x28 */ VK_RETURN, // Return
+        /* 0x29 */ VK_ESCAPE,
+        /* 0x2A */ VK_BACK, // Backspace
+        /* 0x2B */ VK_TAB,
+        /* 0x2C */ VK_SPACE,
+        /* 0x2D */ VK_OEM_MINUS, // -_
+        /* 0x2E */ VK_OEM_PLUS, // =+
+        /* 0x2F */ VK_OEM_4, // [{
+        /* 0x30 */ VK_OEM_6, // ]}
+        /* 0x31 */ VK_OEM_5, // \|
+        /* 0x32 */ 0, // kHIDUsage_KeyboardNonUSPound
+        /* 0x33 */ VK_OEM_1, // ;:
+        /* 0x34 */ VK_OEM_7, // '"
+        /* 0x35 */ VK_OEM_3, // `~
+        /* 0x36 */ VK_OEM_COMMA, // ,<
+        /* 0x37 */ VK_OEM_PERIOD, // .>
+        /* 0x38 */ VK_OEM_2, // /?
+        /* 0x39 */ VK_CAPITAL, // Caps Lock
+        /* 0x3A */ VK_F1,
+        /* 0x3B */ VK_F2,
+        /* 0x3C */ VK_F3,
+        /* 0x3D */ VK_F4,
+        /* 0x3E */ VK_F5,
+        /* 0x3F */ VK_F6,
+        /* 0x40 */ VK_F7,
+        /* 0x41 */ VK_F8,
+        /* 0x42 */ VK_F9,
+        /* 0x43 */ VK_F10,
+        /* 0x44 */ VK_F11,
+        /* 0x45 */ VK_F12,
+        /* 0x46 */ VK_SNAPSHOT, // Print Screen
+        /* 0x47 */ VK_SCROLL, // Scroll Lock
+        /* 0x48 */ VK_PAUSE,
+        /* 0x49 */ VK_INSERT,
+        /* 0x4A */ VK_HOME, // Home
+        /* 0x4B */ VK_PRIOR, // Page Up
+        /* 0x4C */ VK_DELETE, // Forward Delete
+        /* 0x4D */ VK_END, // End
+        /* 0x4E */ VK_NEXT, // Page Down
+        /* 0x4F */ VK_RIGHT, // Right Arrow
+        /* 0x50 */ VK_LEFT, // Left Arrow
+        /* 0x51 */ VK_DOWN, // Down Arrow
+        /* 0x52 */ VK_UP, // Up Arrow
+        /* 0x53 */ VK_CLEAR, // Num Pad Clear
+        /* 0x54 */ VK_DIVIDE, // Num Pad /
+        /* 0x55 */ VK_MULTIPLY, // Num Pad *
+        /* 0x56 */ VK_SUBTRACT, // Num Pad -
+        /* 0x57 */ VK_ADD, // Num Pad +
+        /* 0x58 */ VK_RETURN, // Num Pad Enter
+        /* 0x59 */ VK_NUMPAD1,
+        /* 0x5A */ VK_NUMPAD2,
+        /* 0x5B */ VK_NUMPAD3,
+        /* 0x5C */ VK_NUMPAD4,
+        /* 0x5D */ VK_NUMPAD5,
+        /* 0x5E */ VK_NUMPAD6,
+        /* 0x5F */ VK_NUMPAD7,
+        /* 0x60 */ VK_NUMPAD8,
+        /* 0x61 */ VK_NUMPAD9,
+        /* 0x62 */ VK_NUMPAD0,
+        /* 0x63 */ VK_DECIMAL, // Num Pad .
+        /* 0x64 */ 0, // Non-ANSI \|
+        /* 0x65 */ 0, // Application
+        /* 0x66 */ 0, // Power
+        /* 0x67 */ VK_OEM_PLUS, // Num Pad =. There is no such key on common PC keyboards, mapping to normal "+=".
+        /* 0x68 */ VK_F13,
+        /* 0x69 */ VK_F14,
+        /* 0x6A */ VK_F15,
+        /* 0x6B */ VK_F16,
+        /* 0x6C */ VK_F17,
+        /* 0x6D */ VK_F18,
+        /* 0x6E */ VK_F19,
+        /* 0x6F */ VK_F20,
+        /* 0x70 */ VK_F21,
+        /* 0x71 */ VK_F22,
+        /* 0x72 */ VK_F23,
+        /* 0x73 */ VK_F24,
+        /* 0x74 */ VK_EXECUTE,
+        /* 0x75 */ VK_INSERT, // Help
+        /* 0x76 */ 0, // Menu
+        /* 0x77 */ VK_SELECT,
+        /* 0x78 */ 0, // Stop
+        /* 0x79 */ 0, // Again
+        /* 0x7A */ 0, // Undo
+        /* 0x7B */ 0, // Cut
+        /* 0x7C */ 0, // Copy
+        /* 0x7D */ 0, // Paste
+        /* 0x7E */ 0, // Find
+        /* 0x7F */ VK_VOLUME_MUTE, // Mute
+        /* 0x80 */ VK_VOLUME_UP, // Volume Up
+        /* 0x81 */ VK_VOLUME_DOWN, // Volume Down
+    };
+    // Check if key is a modifier.
+    switch (keyCode) {
+    case kHIDUsage_KeyboardLeftControl:
+        return VK_LCONTROL;
+    case kHIDUsage_KeyboardLeftShift:
+        return VK_LSHIFT;
+    case kHIDUsage_KeyboardLeftAlt: // Left Option
+        return VK_LMENU;
+    case kHIDUsage_KeyboardLeftGUI: // Left Command
+        return VK_LWIN;
+    case kHIDUsage_KeyboardRightControl:
+        return VK_RCONTROL;
+    case kHIDUsage_KeyboardRightShift:
+        return VK_RSHIFT;
+    case kHIDUsage_KeyboardRightAlt: // Right Option
+        return VK_RMENU;
+    case kHIDUsage_KeyboardRightGUI: // Right Command
+        return VK_APPS;
+    }
+    // Otherwise check all other known keys.
+    if (keyCode < WTF_ARRAY_LENGTH(windowsKeyCode))
+        return windowsKeyCode[keyCode];
+    return 0; // Unknown key
+}
+
 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
 {
     // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
index 347ae4f..dad9a0a 100644 (file)
@@ -150,15 +150,9 @@ static int windowsKeyCodeForCharCodeIOS(unichar charCode)
     
     if (keyCode)
         _keyCode = windowsKeyCodeForKeyCode(keyCode);
-
-    // NOTE: this preserves the original semantics which used the 
-    // characters string for the keyCode. This should be changed in iOS 4.0 to
-    // allow the client to explicitly specify a keyCode, otherwise default to 
-    // mapping the characters string to a keyCode.
-    // e.g. add an 'else' before this 'if'.
-    if ([charactersIgnoringModifiers length] == 1) {
-        unichar ch = [charactersIgnoringModifiers characterAtIndex:0];
-        _keyCode = windowsKeyCodeForCharCodeIOS(ch);
+    else if ([charactersIgnoringModifiers length] == 1) {
+        // This event is likely for a software keyboard-generated event.
+        _keyCode = windowsKeyCodeForCharCodeIOS([charactersIgnoringModifiers characterAtIndex:0]);
     }
 
     return self;
@@ -192,17 +186,11 @@ static int windowsKeyCodeForCharCodeIOS(unichar charCode)
     
     if (keyCode)
         _keyCode = windowsKeyCodeForKeyCode(keyCode);
-    
-    // NOTE: this preserves the original semantics which used the
-    // characters string for the keyCode. This should be changed in iOS 4.0 to
-    // allow the client to explicitly specify a keyCode, otherwise default to
-    // mapping the characters string to a keyCode.
-    // e.g. add an 'else' before this 'if'.
-    if ([charactersIgnoringModifiers length] == 1) {
-        unichar ch = [charactersIgnoringModifiers characterAtIndex:0];
-        _keyCode = windowsKeyCodeForCharCodeIOS(ch);
+    else if ([charactersIgnoringModifiers length] == 1) {
+        // This event is likely for a software keyboard-generated event.
+        _keyCode = windowsKeyCodeForCharCodeIOS([charactersIgnoringModifiers characterAtIndex:0]);
     }
-    
+
     return self;
 }
 
index 8947870..c4282fd 100644 (file)
 namespace WebCore {
 using namespace WTF;
 
+int windowsKeyCodeForKeyCode(uint16_t keyCode)
+{
+    static const int windowsKeyCode[] = {
+        /* 0 */ VK_A,
+        /* 1 */ VK_S,
+        /* 2 */ VK_D,
+        /* 3 */ VK_F,
+        /* 4 */ VK_H,
+        /* 5 */ VK_G,
+        /* 6 */ VK_Z,
+        /* 7 */ VK_X,
+        /* 8 */ VK_C,
+        /* 9 */ VK_V,
+        /* 0x0A */ VK_OEM_3, // "Section" - key to the left from 1 (ISO Keyboard Only)
+        /* 0x0B */ VK_B,
+        /* 0x0C */ VK_Q,
+        /* 0x0D */ VK_W,
+        /* 0x0E */ VK_E,
+        /* 0x0F */ VK_R,
+        /* 0x10 */ VK_Y,
+        /* 0x11 */ VK_T,
+        /* 0x12 */ VK_1,
+        /* 0x13 */ VK_2,
+        /* 0x14 */ VK_3,
+        /* 0x15 */ VK_4,
+        /* 0x16 */ VK_6,
+        /* 0x17 */ VK_5,
+        /* 0x18 */ VK_OEM_PLUS, // =+
+        /* 0x19 */ VK_9,
+        /* 0x1A */ VK_7,
+        /* 0x1B */ VK_OEM_MINUS, // -_
+        /* 0x1C */ VK_8,
+        /* 0x1D */ VK_0,
+        /* 0x1E */ VK_OEM_6, // ]}
+        /* 0x1F */ VK_O,
+        /* 0x20 */ VK_U,
+        /* 0x21 */ VK_OEM_4, // {[
+        /* 0x22 */ VK_I,
+        /* 0x23 */ VK_P,
+        /* 0x24 */ VK_RETURN, // Return
+        /* 0x25 */ VK_L,
+        /* 0x26 */ VK_J,
+        /* 0x27 */ VK_OEM_7, // '"
+        /* 0x28 */ VK_K,
+        /* 0x29 */ VK_OEM_1, // ;:
+        /* 0x2A */ VK_OEM_5, // \|
+        /* 0x2B */ VK_OEM_COMMA, // ,<
+        /* 0x2C */ VK_OEM_2, // /?
+        /* 0x2D */ VK_N,
+        /* 0x2E */ VK_M,
+        /* 0x2F */ VK_OEM_PERIOD, // .>
+        /* 0x30 */ VK_TAB,
+        /* 0x31 */ VK_SPACE,
+        /* 0x32 */ VK_OEM_3, // `~
+        /* 0x33 */ VK_BACK, // Backspace
+        /* 0x34 */ 0, // n/a
+        /* 0x35 */ VK_ESCAPE,
+        /* 0x36 */ VK_APPS, // Right Command
+        /* 0x37 */ VK_LWIN, // Left Command
+        /* 0x38 */ VK_LSHIFT, // Left Shift
+        /* 0x39 */ VK_CAPITAL, // Caps Lock
+        /* 0x3A */ VK_LMENU, // Left Option
+        /* 0x3B */ VK_LCONTROL, // Left Ctrl
+        /* 0x3C */ VK_RSHIFT, // Right Shift
+        /* 0x3D */ VK_RMENU, // Right Option
+        /* 0x3E */ VK_RCONTROL, // Right Ctrl
+        /* 0x3F */ 0, // fn
+        /* 0x40 */ VK_F17,
+        /* 0x41 */ VK_DECIMAL, // Num Pad .
+        /* 0x42 */ 0, // n/a
+        /* 0x43 */ VK_MULTIPLY, // Num Pad *
+        /* 0x44 */ 0, // n/a
+        /* 0x45 */ VK_ADD, // Num Pad +
+        /* 0x46 */ 0, // n/a
+        /* 0x47 */ VK_CLEAR, // Num Pad Clear
+        /* 0x48 */ VK_VOLUME_UP,
+        /* 0x49 */ VK_VOLUME_DOWN,
+        /* 0x4A */ VK_VOLUME_MUTE,
+        /* 0x4B */ VK_DIVIDE, // Num Pad /
+        /* 0x4C */ VK_RETURN, // Num Pad Enter
+        /* 0x4D */ 0, // n/a
+        /* 0x4E */ VK_SUBTRACT, // Num Pad -
+        /* 0x4F */ VK_F18,
+        /* 0x50 */ VK_F19,
+        /* 0x51 */ VK_OEM_PLUS, // Num Pad =. There is no such key on common PC keyboards, mapping to normal "+=".
+        /* 0x52 */ VK_NUMPAD0,
+        /* 0x53 */ VK_NUMPAD1,
+        /* 0x54 */ VK_NUMPAD2,
+        /* 0x55 */ VK_NUMPAD3,
+        /* 0x56 */ VK_NUMPAD4,
+        /* 0x57 */ VK_NUMPAD5,
+        /* 0x58 */ VK_NUMPAD6,
+        /* 0x59 */ VK_NUMPAD7,
+        /* 0x5A */ VK_F20,
+        /* 0x5B */ VK_NUMPAD8,
+        /* 0x5C */ VK_NUMPAD9,
+        /* 0x5D */ 0, // Yen (JIS Keyboard Only)
+        /* 0x5E */ 0, // Underscore (JIS Keyboard Only)
+        /* 0x5F */ 0, // KeypadComma (JIS Keyboard Only)
+        /* 0x60 */ VK_F5,
+        /* 0x61 */ VK_F6,
+        /* 0x62 */ VK_F7,
+        /* 0x63 */ VK_F3,
+        /* 0x64 */ VK_F8,
+        /* 0x65 */ VK_F9,
+        /* 0x66 */ 0, // Eisu (JIS Keyboard Only)
+        /* 0x67 */ VK_F11,
+        /* 0x68 */ 0, // Kana (JIS Keyboard Only)
+        /* 0x69 */ VK_F13,
+        /* 0x6A */ VK_F16,
+        /* 0x6B */ VK_F14,
+        /* 0x6C */ 0, // n/a
+        /* 0x6D */ VK_F10,
+        /* 0x6E */ 0, // n/a (Windows95 key?)
+        /* 0x6F */ VK_F12,
+        /* 0x70 */ 0, // n/a
+        /* 0x71 */ VK_F15,
+        /* 0x72 */ VK_INSERT, // Help
+        /* 0x73 */ VK_HOME, // Home
+        /* 0x74 */ VK_PRIOR, // Page Up
+        /* 0x75 */ VK_DELETE, // Forward Delete
+        /* 0x76 */ VK_F4,
+        /* 0x77 */ VK_END, // End
+        /* 0x78 */ VK_F2,
+        /* 0x79 */ VK_NEXT, // Page Down
+        /* 0x7A */ VK_F1,
+        /* 0x7B */ VK_LEFT, // Left Arrow
+        /* 0x7C */ VK_RIGHT, // Right Arrow
+        /* 0x7D */ VK_DOWN, // Down Arrow
+        /* 0x7E */ VK_UP, // Up Arrow
+    };
+    if (keyCode < WTF_ARRAY_LENGTH(windowsKeyCode))
+        return windowsKeyCode[keyCode];
+    return 0;
+}
+
 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
 {
     // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
index acfb680..705f587 100644 (file)
@@ -1,3 +1,18 @@
+2018-09-24  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Key code is 0 for many hardware keyboard keys
+        https://bugs.webkit.org/show_bug.cgi?id=189604
+
+        Reviewed by Wenson Hsieh.
+
+        For a hardware keyboard-generated event (an event with a non-nill event._hidEvent) pass
+        the key code for the event. Otherwise, do what we do now and pass 0 as the event is likely
+        a software keyboard-generated event.
+
+        * Platform/spi/ios/UIKitSPI.h: Add some more SPI.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView handleKeyEvent:]):
+
 2018-09-24  Brian Burg  <bburg@apple.com>
 
         Web Inspector: topContentInset is not accounted for when inspecting a WKWebView and docked to side
index 5d663b5..44698d2 100644 (file)
@@ -998,6 +998,13 @@ typedef NSInteger UICompositingMode;
 
 #endif // USE(APPLE_INTERNAL_SDK)
 
+@interface UIPhysicalKeyboardEvent : UIPressesEvent
+@end
+
+@interface UIPhysicalKeyboardEvent ()
+@property (nonatomic, readonly) CFIndex _keyCode;
+@end
+
 @interface UIColor (IPI)
 + (UIColor *)insertionPointColor;
 @end
index 603af17..27d9792 100644 (file)
@@ -3748,7 +3748,7 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
                                                            modifiers:event._modifierFlags
                                                          isRepeating:(event._inputFlags & kUIKeyboardInputRepeat)
                                                            withFlags:event._inputFlags
-                                                             keyCode:0
+                                                             keyCode:event._hidEvent ? ((UIPhysicalKeyboardEvent *)event)._keyCode : 0
                                                             isTabKey:[event._modifiedInput isEqualToString:@"\t"]
                                                         characterSet:WebEventCharacterSetUnicode] autorelease];
     webEvent.uiEvent = event;