I am building a custom suggestion/autocorrection feature in an iOS app. It must detect accidental adjacent keypresses and compare this to a known word list to suggest the word it thinks the user intended to type.
For example, if the custom word list contains cat
, dog
, monkey
, and the user types cst
, the app can determine that the most likely word was cat
(because s
is adjacent to the a
key)
This will work on a standard QWERTY keyboard, but what happens if the user is using an AZERTY keyboard?
For the autocorrect/suggest to work reliably, the app must be able to detect the keyboard layout in use.
In iOS, it is possible to obtain a UITextInputMode
object from a UITextField
. This object has a primaryLanguage
(string) property, which will display the locale (e.g. en-GB
), but this does not contain enough granularity to distinguish between English (Australia) QWERTY
and English (Australia) AZERTY
. In both cases, the primaryLanguage
is en-AU
.
Is it possible to detect the keyboard layout in iOS?