Well I just had the same problem (lg g3) and I tried to reboot, shut down, remove battery. Then I went to google play store and ticked the microphone and said keyboard, then I chose google keyboard and installed it and set it up. Now I could write, but the real problem wasn't solved. Then I came here and read most of solutions, and what really worked for me was:
1 went to settings,
2 went to applications
3 all applications
4 choose lg key board
Here I tought of updating it but it didn't seem to have any more updates (settings - abour this phone - updates - application updates)
5 Having no updates I just deleted all data. This was that solved the problem.
The advice here is to install the google key board as an alternative. I had no problems at restarting and turning the phone on since I configured the knock code, so I didn't had to input characters, so here is another advice: use different access methods like knock code, finger print, pattern if available instead of alphanumeric access codes.
If you can't install it then you could log in to your google account or play.google and search for google keyboard and select the option to install it remotely.
Fortunately I didn't have to reset to factory settings, so you should try all different options before doing a factory reset.
Hope this helps someone.