[resolved] Change/show different keyboard with Java script

I have successfully implemented Marc’s script to add keyboards to Keyman with Java script, now I need to be able to select/change/show a keyboard.
When I select the keyboard from the Keyman OSK selector, I’m able to grab the ISOcode, but I can’t seem to be able to tell Keyman to display the new keyboard (language).
i.e.

const tags = [‘en’,‘fr’,‘ta’];
kmw.addKeyboards(…tags.map(tag => ‘@’+tag));

I’d like to be able to programmatically change the keyboard display to (for example) French.
Thanks in advance,
Rusty

You can switch keyboards with setActiveKeyboard or for control-by-control presets, you can use setKeyboardForControl.

@RustyE Does the solution Marc provided works for you?

No, I can’t get them to work in the MVC environment.
I’ve tried this:

/script>
var kmw = keyman;

    (function (kmw) {
        kmw.init({ attachType: 'auto' });
        var tags = @Html.Raw(Json.Encode(Model.PreferredKeyboards));
        kmw.addKeyboards(...tags.map(tag => '@@' + tag))
        var alert = confirm("KMW reloading")
        kmw.setDefaultKeyboardForControl('#CKSource', 'en', 'Eng');
        kmw.setDefaultKeyboardForControl('#CKTarget', 'hi', 'hin');
    })(keyman);

/script>
(the /script has had the < removed to pass injection/errors in this blog)
Let me know if you can get this to work.

See conversation continuing in Asp.net Keyman web with ckEditor - #8 by RustyE

I’ll mark this thread as resolved :slight_smile: