Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 18.0Version 17.0 (current version)Version 16.0Version 15.0Version 14.0Version 13.0Version 12.0Version 11.0Version 10.0

On this page

You are viewing an incomplete pre-release version of this documentation. Click here to open the current version, 17.0.

stateMatch (KSM)


Summary

State-key matching: Returns true if the event matches the rule's state-key requirements.

Syntax

keyman.interface.stateMatch(e, shiftCode);

or

KeymanWeb.KSM(e, shiftCode); // Shorthand

Parameters

e : Type: Object : A keystroke-related event object to match.

state : Type: number : The state-key bitflags the event should match.

Return Value

boolean : true if the keystroke matches the desired states, otherwise false.

Description

As of KeymanWeb 10.0, KeymanWeb now supports keyboard rules conditioned upon 'state keys' like Caps Lock if specified by keyboard developers.

The stateMatch function examines the bit-flags to determine the state keys being tested and compares the keyboard event against them as appropriate. As such, it is designed to be a condition check alongside keyman.interface.keyMatch() and keyman.interface.contextMatch().

For comparison with Developer 'rules' from keyboard source code, in the rule

+ [CAPS K_A]  > 'BIG A'
+ [NCAPS K_A] > 'small a'

a keyboard would check which rule the triggering keystroke ("a") matches by using

keyman.interface.stateMatch(e, 0x100)

from within a raised keystroke event with object e, which checks that the keystroke represented by e has an activated Caps Lock state as represented by the code 0x0100. The NCAPS rule would instead compare against 0x0200.

As keyman.interface.stateMatch() receives an event object as one of its parameters, it does not need a direct link to the element receiving input.

See also