我正在尝试制作一个可以输入内容的扩展,但由于某种原因它不会输入减号。我曾尝试使用类型“char”和“keyDown”来输入,但到目前为止没有任何效果。这是我的代码
for (c of message.text.toString()) {
await wait(1000);
console.log(c);
if (c == '-') {
console.log('minus')
chrome.debugger.sendCommand(target, 'Input.dispatchKeyEvent', {
type: 'rawKeyDown',
code: 'Minus',
key: '-',
nativeVirtualKeyCode: 189,
unmodifiedText: '-'
});
chrome.debugger.sendCommand(target, 'Input.dispatchKeyEvent', {
type: 'keyUp',
code: 'Minus',
key: '-',
nativeVirtualKeyCode: 189,
unmodifiedText: '-'
});
} else {
chrome.debugger.sendCommand(target, 'Input.dispatchKeyEvent', {
type: 'char',
text: c
});
}
}