A. Check your device's performance. Close any background apps that may be consuming resources. Go to Settings > Apps and close any unnecessary applications.
B. Consider using a different keyboard app. Some keyboard apps may perform better than others, so try downloading a lightweight keyboard from the Google Play Store.