Index: ui/keyboard/resources/elements/kb-keyboard.html |
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html |
index 93cc165ac1abe2488ec96055ea4439e5c2668c86..2082a84aeae47c3f43cce2b60a858114f4d40ce6 100644 |
--- a/ui/keyboard/resources/elements/kb-keyboard.html |
+++ b/ui/keyboard/resources/elements/kb-keyboard.html |
@@ -23,6 +23,7 @@ |
-- keyboard layouts. |
--> |
<content select="#{{layout}}-{{keyset}}"></content> |
+ <kb-key-codes id="keyCodeMetadata"></kb-key-codes> |
</template> |
<script> |
/** |
@@ -297,12 +298,13 @@ |
} |
if (detail.repeat) { |
- insertText(detail.char); |
+ this.keyTyped(detail); |
repeatKey.key = this.lastPressedKey; |
+ var self = this; |
repeatKey.timer = setTimeout(function() { |
repeatKey.timer = undefined; |
repeatKey.interval = setInterval(function() { |
- insertText(detail.char); |
+ self.keyTyped(detail); |
}, REPEAT_INTERVAL_MSEC); |
}, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC)); |
} |
@@ -435,7 +437,10 @@ |
default: |
break; |
} |
- insertText(char); |
+ if (char.length == 1) |
+ this.keyTyped(detail); |
+ else |
+ insertText(char); |
}, |
/* |
@@ -494,6 +499,17 @@ |
}, |
/** |
+ * Generates fabricated key events to simulate typing on a |
+ * physical keyboard. |
+ * @param {Object} detail Attributes of the key being typed. |
+ */ |
+ keyTyped: function(detail) { |
+ var builder = this.$.keyCodeMetadata; |
+ sendKeyEvent(builder.createVirtualKeyEvent(detail, "keydown")); |
+ sendKeyEvent(builder.createVirtualKeyEvent(detail, "keyup")); |
+ }, |
+ |
+ /** |
* Selects the default keyset for a layout. |
* @return {boolean} True if successful. This method can fail if the |
* keysets corresponding to the layout have not been injected. |