Keyboard Layouts

I am looking for a solution to international keyboard layouts. Currently, i am using Monogame.Extended for the keyboard input listener, but it hard-codes each input to a qwerty keyboard. I saw the discussion on similar issue here Text Input Box (again) about a year ago, but have not seen a viable solution yet. I tried using Game.Windows.TextInput event, but could not get special characters like @ [ {. I have also seen solutions for xna where you can listen to Windows messages, but i’m developing a cross-platform application, so at the moment it’s not a very viable solution. The final solution I have found is to allow users to specify what key equates to what, but that seems hardly reasonable to do. Any solution would be appreciated.

Hi,
yeah, as suggested in the linked topic I used https://github.com/UnterrainerInformatik/Monogame-Textbox as base and made some minor changes.
Most of the special characters are working, but it seems that none of AltGr + [key] characters are beeing detected.
Unfortunately I do not have a solution for that :-/

So you just hard coded the alt functions for the majority of the population? Like the Germarns, Austrieans, Croatians, Serbs, etc.?

I am from Austria myself and the only chars not working are |@{[]}~ (as far as I’ve tested it now) and to be honest, I do not need those in my game and therefore I did not went deeper into it.

Thanks, tried this with Xamarin, but I get a TypeLoadException. Apparently TextInputArgsEvents can only be used in Windows.

Back to looking for another solution…

This might be the solution for you all.

I check if Shift, CTRL and AltGR is pressed like this (VB style)

Dim TempKeys As Keys() = _KeyBoardState.GetPressedKeys
Dim Shift As Boolean = _KeyBoardState.IsKeyDown(Keys.LeftShift) Or _KeyBoardState.IsKeyDown(Keys.RightShift)
Dim CTRL As Boolean = _KeyBoardState.IsKeyDown(Keys.LeftControl) Or _KeyBoardState.IsKeyDown(Keys.RightControl)
Dim AltGR As Boolean = _KeyBoardState.IsKeyDown(Keys.RightAlt)

And then check if AltGR is true first, the reason is that this key gives two key presses: values 162 and 165.
162 is the value of left CTRL.
So if you check for left CTRL key before AltGR, the AltGR is lost. And then this char will appere ¥ (value 165)

If the spesial keys are pressed, then send the value to your Metode/Function to calculate/remap the new value according to the ASCII table

If AltGR = True Then Return GetAltGRChar(CharValue) End If
    If CTRL = True Then
        Return GetCTRLChar(CharValue)
    End If

    If Shift = True Then
        Return GetShiftChar(CharValue)
    End If
 
    //ASCII char, english
    If CharValue > 64 And CharValue < 91 Then
        Return CharValue + 32
    End If

    //Norwegian chars Æ Ø Å
    If CharValue = 198 Or CharValue = 216 Or CharValue = 197 Then
        Return CharValue + 32
    End If

    Return CharValue

</code

Hope this will help you

Zellpop