Wrong characters with german bluetooth keyboard on iOS

Published

I have an iOS app which needs to work with a bluetooth keyboard. So I overrode PressesBegan.

public override void PressesBegan(NSSet<UIPress> presses, UIPressesEvent evt)
{
    var handled = false;

    foreach (UIPress press in presses)
    {
        if(press.Key is UIKey key)
            handled |= Send(key);
    }

    if(!handled)
        base.PressesBegan(presses, evt);
}

private bool Send(UIKey key)
{
    // more code here
}

The Send method is called as expected, but the properties in key are a bit weird.

When I press the key with ^/° at the top left on my German keyboard, then

key.KeyCode = UIKeyboardHidUsage.KeyboardGraveAccentAndTilde but
key.Characters = "<"
with shift it is ">".

When I press the </> key left of Y, then I get

key.KeyCode = UIKeyboardHidUsage.KeyboardNonUSBackslash
key.Characters = "^"
with shift: "°"
with alt: "|".

So the KeyCodes seem to be right, but the Characters for those two keys are mixed up. All other keys are ok when I select the correct keyboard locale. I also get the correct German characters for the umlauts ÄÖÜß.
This is not limited to my app. If I use the iOS Notes app, I get the same – wrong – behavior.

I guess if this were a bug with the keyboard (a Perixx Periboard-804), then the KeyCode would also be wrong. I also connected the same keyboard to an Android device and there I get the correct characters.

Is this a bug in the German keyboard layout of iOS 14.2 or am I doing something wrong?
Can I work around that somehow so that it also works with other international keyboards? I could of course hardcode those KeyCodes and modifiers to my expected characters, but I’m pretty sure, that this would break for other languages.

Source: Xamarin.ios Questions

Published
Categorised as Uncategorised Tagged , , ,

Answers

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq