我有这段代码:
let ime_api = chrome.input.ime;
export const sendKey = (options, cb = null) => {
return ime_api.sendKeyEvents(options, cb);
};
export const sendSpaceKey = (cb) => {
sendKey({
contextID: 0,
keyData: [{
type: 'keydown',
requestId: 'fewfavoihifgyiurhs',
key: ' ',
code: 'Space',
},{
type: 'keyup',
requestId: 'gjsghgusyrurgfkeufygsfr',
key: ' ',
code: 'Space',
}]
}, cb);
};
sendSpaceKey(() => console.log('Space clicked'));
我的manifest.json:
{
"manifest_version": 2,
"name": "Extension",
"version": "1.0.0",
"content_scripts": [
{
"matches": [ "*://*/*" ],
"js": [ "app/content.js" ]
}
],
"permissions": [
"input", "tabs", "storage", "activeTab", "*://*/*"
],
"background": {
"scripts": ["app/background.js"]
},
"input_components": [
{
"name": "Test IME",
"type": "ime",
"id": "test",
"description": "Test IME",
"language": "en-US",
"layouts": ["us::eng"]
}
]
}
Chrome让我回复:
运行input.ime.sendKeyEvents时未经检查的runtime.lastError:引擎不可用
为什么?
答案 0 :(得分:0)
在尝试为Windows上的Chrome开发扩展程序时遇到了这个问题。显然input.ime API仅适用于Chrome操作系统。
https://developer.chrome.com/extensions/input_ime
它在顶部。