- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / templates / intros / input_ime.html
1 <h2 id="manifest">Manifest</h2>
2 <p>You must declare the "input" permission
3 in the <a href="manifest.html">extension manifest</a>
4 to use the input.ime API.
5 For example:</p>
6 <pre data-filename="manifest.json">
7 {
8   "name": "My extension",
9   ...
10   <b>"permissions": [
11     "input"
12   ]</b>,
13   ...
14 }</pre>
15
16 <h2 id="overview-examples">Examples</h2>
17
18 <p>
19 The following code creates an IME that converts typed letters to upper case.
20 </p>
21
22 <pre>
23 var context_id = -1;
24
25 chrome.input.ime.onFocus.addListener(function(context) {
26   context_id = context.contextID;
27 });
28
29 chrome.input.ime.onKeyEvent.addListener(
30   function(engineID, keyData) {
31     if (keyData.type == "keydown" && keyData.key.match(/^[a-z]$/)) {
32       chrome.input.ime.commitText({"contextID": context_id,
33                                    "text": keyData.key.toUpperCase()});
34       return true;
35     } else {
36       return false;
37     }
38   });
39 </pre>
40
41 <p>
42 For an example of using this API, see the
43 <a
44   href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/input.ime/basic/">basic input.ime sample</a>.
45 For other examples and for help in viewing the source code, see
46 <a href="samples.html">Samples</a>.
47 </p>