Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2615)

Unified Diff: ui/keyboard/resources/elements/kb-keyboard.html

Issue 20145004: Switch from text insertion to key press and release events on the virtual k… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/keyboard/resources/elements/kb-key-codes.html ('k') | ui/keyboard/resources/webui/api_adapter.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « ui/keyboard/resources/elements/kb-key-codes.html ('k') | ui/keyboard/resources/webui/api_adapter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698