Investigation: Text Service Framework (TSF) and Keyboards


Windows has an entire API for text input and interaction.

The Text Services Framework (TSF) is a COM framework and API that supports advanced text input and text processing. It is designed to offer advanced language and word processing features to applications. It supports features such as multilingual support, keyboard drivers, handwriting recognition, speech recognition, as well as spell checking and other text and natural language processing functions.


The diagram is below but please see the details at

Architecture of Text Services Framework

Using TSF

TSF can be implemented as an app or as a text service.

For a keyboard, we’d be writing a TSF text service.

  • A text service can obtain text from, and write text to, an application. A text service can also associate data and properties with a block of text. A text service is implemented as a COM in-proc server that registers itself with TSF. When registered, the user interacts with the text service using the language bar or keyboard shortcuts. Multiple text services can be installed.
  • TSF-aware apps can provide the input context or scope (e.g. “url”, “name”, “address”)

On the app side, extensibility is done by the app by implementing interfaces and registering them with TSF.

TSF can read the current "context" from the application, which . The "context" is the characters on the screen around the insertion point.

TSF and Managed Code:
Difficult since text service gets loaded into arbitrary processes, so they need to be small and lightweight, among other reasons.

Legacy apps:
TSF has a table of controls for legacy apps that describes the input scope (e.g. the address bar control in IE5 takes a “url”)

Other notes:
The Tablet PC TIP uses TSF to provide text to apps.