begin rule
Summary
The begin rules define the entry point groups for the keyboard.
Syntax
begin [entrypoint] > use(startGroup)
Parameters
entrypointUnicode,NewContext, orPostKeystroke, orANSI(deprecated). If omitted, assumesANSI.startGroupThe group that will be called.
Description
The begin rule tells Keyman which groups should be entry points to the
keyboard.
Each entry point has a particular purpose:
Unicodethe entry point for a keystroke in a Unicode-aware application. This is the most common entry point for a keyboard. The
startGroupcan be ausing keysgroup, areadonlygroup or a context-only group.NewContextthe entry point into the keyboard when the user enters a new text field, or moves the input cursor into another part of the current text field. This does not imply that there is no context available, but that the context has changed. This is used most commonly to select a starting layer for a touch layout. The
startGroupmust be areadonlygroup.NewContextis currently supported only in Web Core platforms - web, iOS and Android.PostKeystrokethe entry point into a keyboard after keystroke and/or model input event has completed. While some of the same functionality can be replicated by including it in the
begin Unicodeprocessing, this entry point is called after both model input (e.g. selecting a word from the banner), and afternextlayerprocessing from the touch layout, giving the keyboard a chance to adjust the layer and other variable stores. ThestartGroupmust be areadonlygroup.PostKeystrokeis currently supported only in Web Core platforms - web, iOS and Android.ANSI(deprecated)Old Keyman keyboards may include this entry point for a keystroke in a non-Unicode-aware application. This mode is deprecated, and only supported on the Windows platform. If
entrypointis omitted, the ANSI option is assumed, which matches the legacy Keyman 4.0 and olderbeginrule. In this context,ANSImeans the current legacy system codepage for the computer.
A begin rule can be included for each entry point in a single keyboard file.
The right hand side of the begin rule may contain only a use()
statement.
The begin rule is the only rule that is not part of a group, and is required
for every keyboard.
Examples
Example: using begin in a Unicode keyboard
begin Unicode > use(main)
group(main) using keys
Example: using begin NewContext and begin PostKeystroke
See Casing Support for a more comprehensive example.
begin NewContext > use(new)
begin PostKeystroke > use(post)
group(new) readonly
group(post) readonly
Platforms
The begin statement can be used in keyboards on all platforms. In version 15,
not all platforms support all entry points.
| Entrypoint | Windows | macOS | Linux | Desktop web | Mobile web | iOS | Android |
|---|---|---|---|---|---|---|---|
| Unicode | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| NewContext | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ | ✔ |
| PostKeystroke | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ | ✔ |
| ANSI | ✔ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ |
Version history
- Version 15.0:
NewContextandPostKeystrokesupport introduced. - This line originated in SIL-CC, and a simplified version was used in Keyman for consistency. The ANSI/Unicode distinction was introduced in Keyman 5.


