Search code examples
c#vstooffice-interop

Capturing keydown event of MS Word using C#


I'm trying to develop an office add-on and need to capture the keydown event on MS-Word using C#. can somebody give me an example on how i can do that?


Solution

  • This looks like a duplicate of: How to get the "KeyPress" event from a Word 2010 Addin (developed in C#)?

    In that question this answer links to a similar question on the MSDN forum: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/7198a84f-4a37-474b-93b5-1e6f38d5d139. In the accepted answer on the MSDN forum it is stated that:

    there's nothing in the Word API or VSTO that can pick up keystrokes. There's nothing built-in that you can use in a VSTO project to pick up the keystrokes.

    However, the accepted answer on the MSDN forum also talks about a possible solution involving the WindowSelectionChange event - it might be useful to look in to.