Class: ScriptelInternationalization

ScriptelInternationalization

This class is responsible for providing transitional mapping from keyCode to code in lieu of actual browser support. This should not be used from external code and will probably be removed from the library at some point when browser support for code gets more ubiquitous.

new ScriptelInternationalization()

Constructor, creates a new instance of this class.

Members

codeMap

Keyboard map to take codes and translate them to English US keybaords.

Methods

buildTable(sig)

This method is responsible for building the variant table to use.
Parameters:
Name Type Description
sig array.<number> A signature beacon to use to identify a new variant table. Optional.

getCharCode(chr) → {string}

This method attempts to get the code for a particular character using the US mapping.
Parameters:
Name Type Description
chr string Character to look up.
Returns:
Code the character maps to.
Type
string

getKeyCode(code) → {number}

This method attempts to look up a key code for a particular code in the US mapping.
Parameters:
Name Type Description
code string Code to look up.
Returns:
Code if found, false otherwise.
Type
number

getLayout(layout) → {number}

This method is responsible for getting a variant number from a layout name.
Parameters:
Name Type Description
layout string Layout to look up.
Returns:
Number of the variant the layout maps to, or false if it couldn't be found.
Type
number

getPossibilities(chr) → {array.<string>}

This method attempts to get all of the different keyCode possiblities for a particular charater. This is used to tenatively identify characters prior to a signature beacon.
Parameters:
Name Type Description
chr string Character to identify possibilities for.
Returns:
Characters this character could potentially be in other mappings.
Type
array.<string>

identifyBeacon(sig) → {number}

This function will attempt to determine which variant is currently required to process further data based on examining a pre-defined set of becaon characters.
Parameters:
Name Type Description
sig array.<number> Array of five keyCodes.
Returns:
Index of required variant, -1 if no variant is required or false if we couldn't tell.
Type
number

mapCharacter(keyCode, shifted) → {string}

This method attempts to map a keyCode to a pariticular character in the current variant table.
Parameters:
Name Type Description
keyCode number Key code to look up.
shifted boolean Whether or not the shift key was pressed.
Returns:
String representing the mapped character, false if the keyCode wasn't found, undefined if the mapping wasn't found.
Type
string

translateKey(evt) → {string}

This method is used to translate a particular key event into a character for the currently configured variant table. If "code" is available no variant table is used and it just uses code.
Parameters:
Name Type Description
evt DOMEvent DOM event to inspect.
Returns:
A single character representing the mapped keyboard event, false if no mapping was found.
Type
string