Adding Keyboards
There are multiple ways to add and install keyboards into your KeymanWeb installation.
In the examples that follow, please note the use of variable kmw
as shorthand for the tavultesoft.keymanweb
object.
Directly linking a local copy
The most efficient way to utilize a keyboard is to obtain a local copy of it and place this copy in a static location on your website. Once this is done, it can be directly linked into KeymanWeb as follows.
kmw.addKeyboards({
id:'us', // The keyboard's unique identification code.
name:'English', // The keyboard's user-readable name.
language:{
id:'eng', // A three-letter code uniquely identifying the language.
// Please refer to the ISO-639 standard as necessary.
name:'English (US)' // The language's name.
},
filename:'./us-1.0.js'}); // A valid path to the compiled *.js file representing the keyboard.
Custom fonts may also be utilized via the language.font
property. For example:
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
Using a loader script
When Keyman Developer compiles a keyboard, it produces not only a *.js
file for the keyboard itself but
also a keyboard stub loader, which generally uses the same filename suffixed with _load
. The following HTML
tag would work for the above example, but only if both *.js
files are placed in the same directory as the code
page utilizing them due to limitations imposed by the page-loading process.
<script src='./us-1.0_load.js'></script>
Requested from the CDN by language name
To obtain the default Keyman keyboard for a given language, call the following function.
kmw.addKeyboardsForLanguage('Dzongkha');
This example would find the default keyboard for the Dzongkha language. This method will fail if the name doesn't perfectly match any language found in the CDN's repository.
Alternatively, languages may be looked up via their ISO 639 language code as follows:
kmw.addKeyboards('@heb')
The @
prefix indicates the use of the ISO 639 language code, which in this case corresponds with Hebrew.
Requested from the CDN by keyboard name
To obtain a specific keyboard by name or by keyboard name and language code as a pair, see the following:
kmw.addKeyboards('french','european2@swe','european2@nor')
This will install three keyboards - one for French (named, quite simply, "French") and two copies of the EuroLatin2 keyboard - one for Swedish and one for Norwegian.