I want to create a TextInput that starts with capitalisation on but then if its turned off by the user it stays off.
the autoCapitilisation prop offers 'characters' but then it keeps going on again after each new character even if the user has turned it off, if I choose 'words' then it automatically leave capitalisation after the first character :(
You could switch the
autoCapitalization
prop based on the events of the keyboard, the correct way would be to listen for theShift
key, but it seems that key is not supported in theonKeyPress
listener. So in this solution, I check if the character entered is in the lowercase letters range and then switch theautoCapitalization
tonone
and set it tocharacters
whenever the keyboard is shown.https://snack.expo.io/@diedu89/textinput-autocapitalize
Note: I tested this on an android device, and it worked. It doesn't work in the iOS emulator on snack.expo, not sure if it is because of the emulator or a react-native bug.