In WinForms the integral value of Keys enum elements matches their virtual key code, so you could assign key labels like this -
// using Keys = System.Windows.Forms.Keys;
var bg = new CultureInfo("bg-BG");
var en = new CultureInfo("en-US");
kb.SetKeyLabels(bg, new []
{
new KeyLabels { VirtualKey = (int)Keys.Q, Lower = "Яя"},
});
kb.SetKeyLabels(en, new[]
{
new KeyLabels { VirtualKey = (int)Keys.Q, Lower = "Qq"},
});
Sadly, SetKeyLabels supports only RegularKey and NumPadKey labels at this time, while Shift, Back, Space etc are instances of SpecialKey. We'll have in mind extending it to support the latter for next release. For time being you could save two different versions of your custom layout for the two languages, using the default name suggested by Keyboard Creator that includes a layout id, and then place them in a folder pointed by keyboard's LayoutsFolder property. That should load them dynamically when the language changes. Alternatively you could alter the layouts dynamically like this -
var layout = KeyboardLayout.Create("KeyLayout_UserReg.xml");
var newLayout = new KeyboardLayout();
foreach (var key in layout.Keys)
{
var sk = key as SpecialKey;
if (sk != null && sk.VirtualKey == (int)Keys.Space)
{
var s2 = (SpecialKey)sk.Clone();
s2.Content = "Интервал";
newLayout.Keys.Add(s2);
}
else
{
newLayout.Keys.Add(key);
}
}
kb.TemplateLayout = newLayout;
Regards,
Slavcho