Keyboard Support

Contact and Search Homepage

Header bottom

Other versions
Version 15.0 (current version)Version 14.0Version 13.0Version 12.0Version 11.0Version 10.0Version 2.0Version 1.0 (home page)

On this page

Manual Language Control

In this example, the web page designer has opted for their own user interface instead of the KeymanWeb interface. The keyboards in the selector are populated from the KeymanWeb list of keyboards.

Code Walkthrough

Include the following script in the HEAD of your page:

  var KWControl = null;
  var kmw = tavultesoft.keymanweb;
  /* SetupDocument: Called when the page finishes loading */
  function SetupDocument()
    /* Make sure that Keyman is initialized (we can't guarantee initialization order) */
    KWControl = document.getElementById('KWControl');
    /* Retrieve the list of keyboards available from KeymanWeb and populate the selector using the DOM */
    var kbds = kmw.getKeyboards();
    for(var kbd in kbds)
      var opt = document.createElement('OPTION');
      opt.value = kbds[kbd].InternalName + "$$" + kbds[kbd].LanguageCode;
      opt.innerHTML = kbds[kbd].Name;
    /* Focus onto the multilingual field in the form */
    // Ensures the default keyboard is active, to match our listbox's initial (default) option.
  /* KWControlChange: Called when user selects an item in the KWControl SELECT */
  function KWControlChange()
    /* Select the keyboard in KeymanWeb */
    var name = KWControl.value.substr(0, KWControl.value.indexOf("$$"));
    var languageCode = KWControl.value.substr(KWControl.value.indexOf("$$"+2));
    kmw.setActiveKeyboard(name, languageCode);
    /* Focus onto the multilingual field in the form */

Also include the following HTML code:

    <!-- Load the KeymanWeb engine -->
    <script src="keymanweb.js" type="text/javascript"></script>
    <!-- Load the your keyboard stubs here -->
    <script src="laokeys_load.js" type="text/javascript"></script>
    <!-- ... -->

<!-- When the page has finished loading, populate the keyboard selector, see above -->
<body onload="SetupDocument()">

And finally, include the keyboard SELECT and the clickable help img:

<!-- Display the KWControl selector with different keyboards listed -->
<p>Keyboard: <select id='KWControl' onchange='KWControlChange()'><option value=''>English</option></select>

On programmatically setting the keyboard: tavultesoft.keymanweb.setActiveKeyboard().

On getting KeymanWeb's managed list of keyboards: tavultesoft.keymanweb.getKeyboards().

On to Control by Control Example