Topic Dynamically add & remove keyboard via javascript
We have two new locations for Keyman technical support:
The Tavultesoft Forums are now read only.
| # Dynamically add & remove keyboard via javascript   2014-12-11 09:06:27.980 | 
|---|
Matt
  | I am using KeymanWeb 2.0 (build 376).
 
I have a HTML select list of languages on my test form.
 
When the user selects a language name from the select list, the keyboard is dynamically added to the form.
 
I can do this with the following code:
     
 
	  | : | 
	 
	
	  
 
    (function(kmw) {
 
        kmw.init();
 
        ....
 
        } else if ($("#id_language_code").val() == 'sq' ) {
 
            kmw.addKeyboards('albanian');
 
        }
 
        ....
 
    })(tavultesoft.keymanweb);
 
     | 
	 
 
As I only want to display one KeymanWeb keyboard at any time, how do I dynamically remove the existing keyboard from the form? | 
| # RE: Dynamically add & remove keyboard via javascript   2014-12-11 11:25:58.017 | 
|---|
Tavultesoft Tavultesoft Staff | Thanks for the question.  There as an API call to remove keyboards as well, and we will post the answer on this forum after confirming that it works correctly.    | 
| # RE: Dynamically add & remove keyboard via javascript   2014-12-11 11:49:12.630 | 
|---|
Tavultesoft Tavultesoft Staff | The call:
 
 
keymanweb.removeKeyboards(keyboardName1,keyboardName2,...);
 
 
will unload previously loaded keyboards by name.
 
 
So, for example, if you have used:
 
 
 keymanweb.addKeyboards("georgian"); 
 
 
to load the standard keyboard layout for Georgian (Keyboard_georgian), you would use:
 
 
keymanweb.removeKeyboards("georgian");
 
 
to unload it again.
 
 
Hope this helps!  | 
| # RE: Dynamically add & remove keyboard via javascript   2014-12-11 14:02:04.010 | 
|---|
Matt
  | Thank you for the response.
 
 
That did help me enormously.
 
 
To complete this task, how do I confirm the name of the KeymanWeb keyboard that is loaded or in use on the form.
 
 
Attempting to remove a keyboard that does not exist, returns an error.
 
 
Thanks in advance.  | 
| # RE: Dynamically add & remove keyboard via javascript   2014-12-12 07:28:34.567 | 
|---|
Marc Durdin Tavultesoft Staff | You should be able to call  keymanweb.getKeyboards() to retrieve an array of the currently registered keyboards. See  http://help.keyman.com/developer/engine/web/2.0/reference_kmw20_core_getKeyboards.php for more detail (and yeah, we're working on the documentation...)  | 
| # RE: Dynamically add & remove keyboard via javascript   2014-12-12 07:29:08.250 | 
|---|
Marc Durdin Tavultesoft Staff | I've also logged an issue to address the error attempting to remove an unregistered keyboard. It should return false but not an error in this case, I guess.  |