Keyboard Support

Contact and Search Homepage

Header bottom

On this page

(image: Keyman icon)Groups

Using Groups

Groups provide a facility for grouping related rules, similar to functions in other programming languages. When used effectively, groups can reduce thesize and complexity of your keyboards significantly.

Groups can match on context only, or on context and keystroke. The context-only groupscan be very useful for pre- and post-processing rules, such as reordering stackeddiacritics.

The examples below show the two types of groups.

group(mygroup)                   c context only  'a' > 'b'group(mygroup) using keys        c context and keystroke  'a' + 'a' > 'c'

The use statement allows you move into another group when a ruleis matched. All output from the current group is processed into the context before thesubsequent group is entered (although it is not sent to the application until processingfinishes for the current keystroke). For example,

c This example prohibits two vowels in a rowbegin > use(precheck)group(precheck)  any(vowel) > context use(vowelstate)                                                               nomatch > use(nostate)group(vowelstate) using keys  + any(vowel) > beep  nomatch > use(nostate)group(nostate) using keys  + any(cons) > index(cons, 1)

Several important things to note from this example:

The first rule (any(vowel) > context use(vowelstate)) uses the context keyword to copy the matched context to the output, so thatKeyman can move it back into the context for use with the vowelstate group. If you do not do this,the context will be dropped before vowelstate is used, and the character will be deleted from thescreen.

If the final group processed is a context and keystroke group ("using keys"), and there is not a nomatch rule, and the keystroke is not matched in the group, the keystroke will be output to the screen, regardless of whether or not it was matched in earlier groups.

For another example of a keyboard using multiple groups, seeAdvanced Keyboard Creation.

The following statements and special rules are used with groups: