I'm working on the react js Office add-in Projects. I have already been able to create the sidebar and get the Word header, body and footer content using this code.
await Word.run(async (context) => {
const header = context.document.sections.getFirst().getHeader("Primary").getOoxml();
const body = context.document.body.getOoxml();
const footer = context.document.sections.getFirst().getFooter("Primary").getOoxml();
await context.sync();
saveDocument({
fileName: "test file",
headerXml: header.value.toString(),
bodyXml: body.value.toString(),
footerXml: footer.value.toString()
});
});
And also I want to get the real-time keyboard event. I tried this example:
doc.addHandlerAsync(Office.EventType.DocumentSelectionChanged, function (eventArgs: any) {
console.log(eventArgs);
});
But I can't figure out the entered key from the object. Here I have attached the image that I get from this console.log
:
I need a solution to capture the real-time keyboard inputs that enter in the word document from the add-in.