`keyman.interface` - the Keyboard API
The KeymanWeb core object window.keyman.interface exposes a number of
functions for low-level processing of input, context and output. These functions
are designed for use by keyboards compiled through Keyman Developer in order to
facilitate input text processing and will also work for custom-coded KeymanWeb
keyboards. These functions should only be called by keyboard code, and a good
understanding of the Keyman Keyboard Language will prove
extremely beneficial toward understanding the keyboard API functions enumerated
in this section.
The KeymanWeb Keyboard API publishes a deprecated global KeymanWeb which is
the same as keyman.interface. Use keyman.interface in preference to
KeymanWeb.
Custom user interfaces should not use these functions. These functions are intended for use in a keyboard context, in particular during a keystroke event cycle.
anyFunction (Deprecated)- Returns whether or not the char
chis found within theany(store) string, setting an internally-tracked index for use in theindexOutputfunction. - Shorthand name:
keyman.interface.KA beepFunction- Flash body or element as substitute for an audible feedback
beep. - Shorthand name:
keyman.interface.KB beepResetFunction- Cancels a previous feedback
beepoperation on a page element. - Shorthand name:
keyman.interface.KBR contextFunction (Deprecated)- Gets
contextfor an ongoing keyboard operation relative to the caret's present position. - Shorthand name:
keyman.interface.KC contextExOutputFunction- Emits the character or object at
contextOffsetfrom the current matched rule's context. - Shorthand name:
keyman.interface.KCXO contextMatchFunction (Deprecated)- Context matching: Returns
trueif the specifiedcontextcall matches a provided string. - Shorthand name:
keyman.interface.KCM deadkeyMatchFunction (Deprecated)- Deadkey matching: Seeks to match the
deadkeystatedkat the relative caret positionn. - Shorthand name:
keyman.interface.KDM deadkeyOutputFunction- Deadkey output: Associates the
deadkeystatedkwith the element at the current caret position, after overwritingndcharacters. - Shorthand name:
keyman.interface.KDO deleteContextFunction- Context deletion - removes the specified number of deadkeys and characters from the left of the caret.
- Shorthand name:
keyman.interface.KDC focusLastActiveTextStoreFunction- Set focus to the currently-focused or most recently focused text store.
fullContextMatchFunction- Context matching: Returns
trueif the current context matches the specified rule context specification. - Shorthand name:
keyman.interface.KFCM getLastActiveTextStoreFunction- Get the currently or most recently focused text store. This is for use by IME keyboards.
ifStoreFunctionifStorecompares the content of a systemstorewith a string value.- Shorthand name:
keyman.interface.KIFS indexOutputFunction- Index-based output: Outputs a mapped character according to a previous selection from a
keyman.interface.any()call upon astorestring, after deletingndcharacters. - Shorthand name:
keyman.interface.KIO insertTextFunction- Inserts a text string and optional
deadkeyinto the active output element. - Shorthand name:
keyman.interface.KT isKeypressFunction- Returns
trueif the input event corresponds to a keypress event resulting in character output. - Shorthand name:
keyman.interface.KIK keyInformationFunction- Returns an object with extended information about a specified keystroke event.
- Shorthand name:
keyman.interface.KKI keyMatchFunction- Keystroke matching: Returns
trueif the event matches the rule's shift mask and key code. - Shorthand name:
keyman.interface.KKM loadStoreFunction- Load an option
storevalue from a cookie or default value if no prior stored value exists. - Shorthand name:
keyman.interface.KLOAD nulFunctionnulcontext check: Returnstrueif the length of thecontextis less than or equal toncharacters.- Shorthand name:
keyman.interface.KN outputFunction- Outputs the specified string to an element, overwriting characters before the caret if specified.
- Shorthand name:
keyman.interface.KO registerKeyboardFunction- Register the keyboard stub and load the keyboard.
- Shorthand name:
keyman.interface.KR registerStubFunction- Register the keyboard stub, return true if already registered.
- Shorthand name:
keyman.interface.KRS saveFocusFunction- Save focus: Temporarily saves keyboard processing data for the currently-focused control.
- Shorthand name:
keyman.interface.KSF saveStoreFunction- Save an option
storevalue to a cookie for the active keyboard. - Shorthand name:
keyman.interface.KSAVE setStoreFunctionsetStoresets the value of a systemstoreto a string.- Shorthand name:
keyman.interface.KSETS stateMatchFunction- State-key matching: Returns
trueif the event matches the rule's state-key requirements. - Shorthand name:
keyman.interface.KSM
Deprecated functions for IMEs
The following functions have been retained for compatibility with existing IME keyboards, but should not be used in any new keyboards or user interfaces.
GetLastActiveElementorgetLastActiveElementFunction (Deprecated)- Use
keyman.interface.getLastActiveTextStore() FocusLastActiveElementorfocusLastActiveElementFunction (Deprecated)- Use
keyman.interface.focusLastActiveTextStore() HideHelporhideHelpFunction (Deprecated)- Use
keyman.osk.hide() ShowHelporshowHelpFunction (Deprecated)- Use
keyman.osk.setPos()Usekeyman.osk.show() ShowPinnedHelporshowPinnedHelpFunction (Deprecated)- Use
keyman.osk.setRect() - Use
keyman.osk.show()


