1) Try and Force Restart your iPhone exactly as shown below and see whether that resolves the issue:
- Press and quickly release Volume UP button
- Press and quickly release Volume DOWN button
- Press and Hold the SIDE button until an Apple logo appears then release the Side button (Can take up to 20 seconds. DO NOT release Side Button when invited to Slide Power OFF).
(2) If the above does not work then - Remove any case that you may have on your iPhone and try again. Determine whether the case was affecting the operation of your iPhone's key strokes.
(3) If the above does not work then - Check to see whether you have a screen protector installed. You can remove the screen protector and try again. Determine whether the screen protector interfered with the operation of your iPhone's key strokes. NOTE that you may not be able to use the same screen protector again after you remove it.
(4) If that does not help your phone might need service ➔ Contact Apple for support and service - Apple Support
Axel F.