Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 8.0

Index

On this page

Programmer's Guide - 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.

Using Rules

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.

Some of the important functions that can be used in rules are context, nul and beep.

context

The context keyword 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(n):

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

This will output "Db" when "abcd" is typed.

nul

nul is used in the output of a rule to give the rule no output. For instance, the backslash key may be invalid in the keyboard you are creating, so the following rule will mean it will never have any output:

+ '\' > nul
      

beep

beep is the same as nul, except that the computer will emit a beep sound at the same time to alert the user to the error. You can use this, for instance, when the user types the same diacritic twice in a row:

'è' + '`' > context beep
      

The context statement is required here so that the rule does not delete the "è" character.