Try Settings, Apps, All, scroll to your keyboard app, select Clear Cache. Power Off the Phone and Restart.
If no go, do everything the same, but select Clear Data as well.
You may wish to consider installing a different keyboard on the phone, rather than continue to use the stock one, if the problem persists. Here are some examples of third-party keyboards:
http://www.androidauthority.com/the-best-keyboard-for-android-apps-198452/
Posted via Android Central App