The text input component needs a slight timeout to allow the value to update. See the forum post Give the TextInput onKeyPress Function some time for more information.
Once you have the correct value, you can then parse the string into an array of words. The size of the array is the number of words in the input string.