4
votes

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:

  1. 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?

  2. 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

1
These two questions are unrelated to each other. I'll answer the first here. Please edit and create a new post for the second. Thanks! - Michael Saunders

1 Answers

6
votes

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:

  • Any arrow key press
  • Enter
  • Tab
  • Clicking to position the cursor in the document (not a key press)
  • The first key press of any kind (letter, number, etc.) that immediately follows one of the above types of key press.

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