There is already a crude toy out there that will 'read your mind' and raise or lower a ball based on a signal you send it, you just train it to a binary state. I've heard it described as mellowing out vs concentrating hard.
There's no reason in principle that a reader with fine enough discrimination couldn't be trained to recognize a few hundred states, and you couldn't be trained to 'think' a few hundred things, where the reader would recognize and translate the pattern into a number, letter, or symbol. I'm no neurologist so I have no idea how these things actually work, but it seems easier in theory than understanding the whole of brain and language.
Edit: Note, I can imagine the need for direct text input being reduced over the next 20 years thanks to UI changes ("Select your house on this map" replacing "Type your address in this box", for example), but I don't think that the keyboard will go away as the main tool for doing it when it is needed.