you can use this code. The isTrusted event will be true.
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status == "complete") {
if (tab.url.indexOf("instagram") != -1) {
chrome.debugger.attach( {tabId: tab.id}, "1.2", async function() {
setTimeout(function(){
//opts = {type: "mousePressed", button: "left", x: 557, y: 204, clickCount: 1};
//chrome.debugger.sendCommand({tabId: tab.id}, "Input.dispatchMouseEvent", opts);
//opts0 = {type: "mouseReleased", button: "left", x: 557, y: 204, clickCount: 1};
//chrome.debugger.sendCommand({tabId: tab.id}, "Input.dispatchMouseEvent", opts0);
opts1 = {type: "keyDown", code: "KeyA", key: "a", text: "a"}
chrome.debugger.sendCommand({tabId: tab.id}, "Input.dispatchKeyEvent", opts1);
chrome.debugger.sendCommand({tabId: tab.id}, "Input.dispatchKeyEvent", {type: "keyDown", code: "KeyB", key: "b", text: "b"});
//opts2 = {type: "keyUp", code: "KeyA", key: "a"}
//chrome.debugger.sendCommand({tabId: tab.id}, "Input.dispatchKeyEvent", opts2);
}, 5000);
})
}
}});