MacBook Pro asks to reset password, but neither keyboard nor mousepad are working
I've solved the problem this way.
Turned off the computer manually by holding down the power button.
Attached an external mousetrack (Apple Magic Mouse 2) by USB.
Turned on the computer in recovery mode, by holding down the Command + R keys simultaneously while starting the computer, and releasing only when the Apple logo appeared.
When the recovery screen appeared, I used the Apple menu on the top left corner to restart the computer. It wasn't enough to tap the mousetrack in order to select the desired menu item, I had to forcefully press down on its surface.
The restart proceeded normally. Hurrah!