Keyboard Support

Contact and Search Homepage

Header bottom

On this page

Using rules

A rule is the basic part of a Keyman keyboard. Each rule defines what a keystroke will output, when certain characters are already displayed on the screen. A rule is also used to pre-process and post-process the characters being output to the screen.

A rule is made up of three parts:

context + keystroke > output

The context refers to what is already displayed on the screen. A rule will only be fired if the context and the keystroke both match. The output will replace the context matched on the left hand side of the rule.

In advanced groups, the keystroke section of the rule may be omitted for processing on the context and output.

One of the important statements that can be used in rules is the context statement.

Rule Order

Rules have a special order. They are ordered first by length of context, with longest context first, and then by line order in the file. This slightly non-intuitive ordering makes it much simpler to group rules according to their function, rather than necessarily by their priority.

See also groups.


The context statement will transfer the context of the rule into the output, for example:

"abc" + "d" > context "D"

will, when abc is on the screen, and d is pressed, replace abc with abcD. You can also put a single character from the context into the output using context():

"abc" + "d" > "D" context(2)

This will output Db when abcd is typed.