MacBook Pro asks to reset password, but neither keyboard nor mousepad are working

I've solved the problem this way.

  1. Turned off the computer manually by holding down the power button.

  2. Attached an external mousetrack (Apple Magic Mouse 2) by USB.

  3. 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.

  4. 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.

  5. The restart proceeded normally. Hurrah!