Reputation: 377
I would like to develop an office add-in for Microsoft Word using HTML5/Javascript API and I need your help with the following questions:
Does the Word Javascript API have an event for "on key pressed"? so any time the user is typing in the document I will be able to catch that event on my add-in?
Is it possible to install a Word Add-in directly without using the office store? so I can bundle my add-in into my own installer (for example NSIS installer)
Thanks Shai
Upvotes: 4
Views: 1751
Reputation: 11
UPDATE 2022
The example of Michael Saunders is still working, but it covers also other keys, making it much more useful; basically the event fires everytime the cursor moves:
what is still not handled is any key which doesn't make the cursor move:
Tested on Word 365 (Version 2208)
Upvotes: 0
Reputation: 2668
There's no API for on on-key-pressed event.
The closest option is the DocumentSelectionChanged API event, which fires every time the user's selection changes. In Word, this event fires on some key presses, such as:
Here's the sample:
var doc = Office.context.document;
doc.addHandlerAsync(Office.EventType.DocumentSelectionChanged, function(eventArgs){
// do something when the selection changes
});
-Michael Saunders, program manager for Office add-ins
Upvotes: 6