Here’s how to recalibrate the Auto-Brightness sensor:
Open theSettingsapp, scroll down, and selectAccessibility.
SelectDisplay & Text Size, then turn off theAuto-Brightnesstoggle switch.
Here’s how to double-check that your gear is handling this for you:
OpenSettings.

Turn on theLocation Servicestoggle switch, then scroll down and tapSystem Services.
Turn on theCompass CalibrationandMotion Calibration & Distancetoggle switches.
The iPhone uses your location data to ensure the gyroscope, GPS, compass, and accelerometer work properly.

The phone may show a low percentage but last an hour or two longer.
Or, it may show a full battery and shut down suddenly.
Calibrate the iPhone battery to fix the way the phone monitors and reports the percentage of remaining battery power.
Fully discharge the phone.
Use up the battery power until it shuts off.
Leave the phone discharged and unplugged overnight to completely drain the battery.
Reboot the phone, then perform asoft reset(also called a warm reset).
If problems persist, it may be necessary toreplace the battery.
If problems persist,contact Apple Support.
Alternately,install a custom keyboardthat fits your needs.