Use the chrome.input.ime module to implement a custom IME for
Chrome OS.
This allows your extension to handle keystrokes, set the composition, and
manage the candidate window.
You must declare the "input" permission in the extension manifest to use the input.ime API. For example:
{
"name": "My extension",
...
"permissions": [
"input"
],
...
}
The following code creates an IME that converts typed letters to upper case.
var context_id = -1;
chrome.input.ime.onFocus.addListener(function(context) {
context_id = context.contextID;
});
chrome.input.ime.onKeyEventAsync.addListener(
function(engineID, keyData) {
if (keyData.type == "keydown" && keyData.key.match(/^[a-z]$/)) {
chrome.input.ime.commitText({"contextID": context_id,
"text": keyData.key.toUpperCase()});
return true;
} else {
return false;
}
});
For an example of using this API, see the basic input.ime sample. For other examples and for help in viewing the source code, see Samples.